Skip to main content

Glassfish CDI in OSGi webapp with JSF2

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2013-06-12


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:

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.


Simon Priest

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
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: