JSF Tip #54 - Enable CDI when bundling JSF
Note this blog is obsolete, see https://www.manorrock.com/blog/ for the current blog
Occasionally, users have the need to override the version of JSF included in the application server by bundling a different version of JSF with their application. If you are trying to use CDI in such a scenario, you might have noticed it does not work. Is there a way out?
Yes, there is, by including a small JAR and some configuration in your web application you can make this scenario work.
Add the following Maven dependency to your web application.
Then add the following beans.xml to your WEB-INF directory and you are set to go!
<?xml version="1.0" encoding="UTF-8"?>
Note this particular version of the JAR requires you to use this on a JavaEE6 container that bundles a CDI 1.0 implementation, like Glassfish 22.214.171.124 or Weblogic 12.1.2.
And that is it.