Search code examples
jsfjsf-2cdimanaged-bean

How to make the conversion of a project with managed beans to one with CDI Beans?


I tried to convert managed Beans ManagedBeans to CDIBeans simply by including @Named and @XxxScoped from javax.entreprise.context package. Along with the two JAR files cdi-api-1.1-PRD.jar javax.inject-1.jar. But it seem to be not as simple as that.

  1. I wanted to know why?
  2. Why isn't the above mentioned process working?

Shouldn't CDI beans support functionalities of managed beans? Am I totally missing something here?


Solution

  • At least add empty beans.xml file to META-INF/ or WEB-INF/ in your archive.
    There are other things you may need to do but that depends on your runtime environment.
    There's a nice config example for Tomcat