Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-5564

@EJB doesn't work for JSF 1.2

XMLWordPrintable

    • Hide

      There are two workarounds. First, you can still get a reference to your EJB via JNDI:

      SimpleEJB ejbFromJNDI = (SimpleEJB)new InitialContext().lookup("java:module/SimpleEJB");

      Or, you can change the classloading behavior in the web subsystem. If you do this then JSF 2.x won't work, but JSF 1.2 will work.

      Edit <jboss_home>/modules/org/jboss/as/web/main/module.xml

      Under the dependencies section, change

      <module name="com.sun.jsf-impl"/>

      to

      <module name="com.sun.jsf-impl" slot="1.2"/>

      That will cause the web subsystem to link to the 1.2 version of the InjectionProvider and @EJB will work.

      Show
      There are two workarounds. First, you can still get a reference to your EJB via JNDI: SimpleEJB ejbFromJNDI = (SimpleEJB)new InitialContext().lookup("java:module/SimpleEJB"); Or, you can change the classloading behavior in the web subsystem. If you do this then JSF 2.x won't work, but JSF 1.2 will work. Edit <jboss_home>/modules/org/jboss/as/web/main/module.xml Under the dependencies section, change <module name="com.sun.jsf-impl"/> to <module name="com.sun.jsf-impl" slot="1.2"/> That will cause the web subsystem to link to the 1.2 version of the InjectionProvider and @EJB will work.

      If you use the JSF 1.2 implementation that ships with AS, then if you use @EJB with JSF managed beans then the EJB will not be injected. As a workaround you can get a reference via JNDI.

      For the fix, we need to break out the injection classes into a separate module. This way, we can make the JSFInjectionProvider link to the interface in the proper JSF impl.

              ssilvert@redhat.com Stan Silvert
              ssilvert@redhat.com Stan Silvert
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: