Vaadin-CDI use in ear with skinny wars

Hello,
We are porting our app from cdi-utls to the ‘official’ Vaadin CDI addon and I am having an issue getting CDI to work properly.

We have a ear structure with skinny wars built using Maven
ear
|
±ejb.jar
|
±ui.war
|
±lib*.jar

All the libs reside in the lib directory and the war and ejb manifest also reflects this. The vaadin-cdi-1.0.0.alpah1.jar is there also.

My ui war has a empty bean.xml file within the WEB-INF and no web.xml or jboss-web.xml file (we used to have them, but I will migrate this once the UI ‘starts’).

My ui class looks like this …

@SuppressWarnings(“serial”)
@CDIUI(value=“ui”)
@PreserveOnRefresh
public class MyUI extends UI {

@WebServlet(urlPatterns = "/*", initParams = { //
        @WebInitParam(name = VaadinSession.UI_PARAMETER, value = "com.bla.bla.ui.MyUI"), //
        @WebInitParam(name = Constants.PARAMETER_WIDGETSET, value = "com.bla.bla.ui.MyWidgetset"), //
        @WebInitParam(name = Constants.SERVLET_PARAMETER_UI_PROVIDER, value = "com.vaadin.cdi.CDIUIProvider") //
        })
public static class UIApplicationServlet extends VaadinServlet {
    // NO-OP
}


@Inject
private NavigatorContainer navigator;

@Inject
private CookieManager cookieManager;

@Inject
private MainView mainView;

@Inject
private LocalizationService localizedText;

@Inject
private SystemMessagesProviderImpl systemMessagesProvider;

@Inject
EventService eventService;

@Inject
UserService userService;

@Inject
private LocaleSelection localeSelection;

/* Root layout */
CssLayout root = new CssLayout();

@PostConstruct
private void init() {
    eventService.register(this);
}

@Override
protected void init(final VaadinRequest request) {
    setSystemMessagesProvider();
    initializeNavigator();

    setContent(root);
    root.addStyleName("root");
    root.setSizeFull();

    // Once everything is setup, we go ahead and localize
    handleCookies(request);
}

My issue is that none of my injection points get injected and I don't see my UI getting registered like mentionned in the example:

INFO 1 beans inheriting from UI discovered!
INFO Available Vaadin UIs for CDI deployment [exampleCDIUI]

I am using Vaadin 7.1.6 and I am deploying on JBoss 7.1 but it seems WildFly gives me the same behaviour

Any help would be appreciated ...
Thanks !

After a lot of fiddling, I finally got it to work, seems like Vaadin has classloading issue when used in a ear with skinny wars.
I had to use the packaging defined in the first post
here
to get the CDI detection of the UI working properly.
Then I had to use the solution
here
to enhance the classloader in order to detect my beans properly.
With those two pieces in place, things worked like planned.

I can’t see how vaadin-cdi placed inside EAR\lib is supposed to work. Sure, CDI portable extension should be discovered, but
com.vaadin.cdi.internal.ContextDeployer
is using
@WebListener
annotation that
should not
work when placed in EAR\lib as mandated by the Servlet 3 spec which states

[i]
11.3.1 Provision of Listener Classes

The Developer of the Web application provides listener classes implementing one or
more of the listener interfaces in the javax.servlet API. Each listener class must
have a public constructor taking no arguments.
The listener classes are packaged
into the WAR, either under the WEB-INF/classes archive entry, or inside a JAR in
the WEB-INF/lib directory.

[/i]