Skip to main content

Glassfish 3.1.2.2: CDI in OSGi webapp with JSF2

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
simon_priest
Offline
Joined: 2013-06-12

Hi,

I'm trying to put together a hybrid OSGi/EE6 web app, using the maven-bundle-plugin to build my WAR. The project includes CDI beans which are being referenced in the JSF pages. When deploying to Glassfish as a regular web application, everything works - this is all familiar territory to me. However when I deploy the same WAR with the OSGi type, my CDI beans are no longer visible in the JSF pages. JSF2 managed beans in the same application still work, however.

I found a post similar to mine here:
https://www.java.net//node/705454

But this refers to injecting into a servlet. I've tested this in my project and if I add a servlet class I can inject my beans into it just fine. In addition, the @OsgiService Glassfish CDI extension is working just fine. So is something going wrong with the FacesServlet? Is it possible to use CDI for a JSF-based WAB on Glassfish, has anyone done this? The official guide mentions that all of EE6 should be available to OSGi web apps but it doesn't seem to work in practice.

Thanks,

Simon Priest

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
simon_priest
Offline
Joined: 2013-06-12

I seem to have fixed it. It seems Weld wasn't configuring itself, so adding the appropriate entries to faces-config.xml made my beans visible in pages again:


org.jboss.weld.environment.servlet.jsf.WeldApplicationFactory


org.jboss.weld.jsf.ConversationAwareViewHandler

org.jboss.weld.jsf.WeldPhaseListener