2 Replies Latest reply on Sep 26, 2008 3:50 AM by Emanuel Muckenhuber

    @EJB remote access from JSF backing bean, Resolution should

    Nicole Schweighardt Novice

      Hi,

      I use JBoss5 CR2 and I am trying to get access to an ejb from a jsf backing bean.

      @Remote
      public interface Initialization {
       public void createStock();
      }



      @Stateless
      public class InitializationBean implements Initialization {
      
       @PersistenceContext(unitName="shopejbjsf")
       EntityManager em;
      
       public InitializationBean(){
      
       }
      
       public void createStock() {
      ...
       }
      }


      JSF Backingbean:

      public class ShopBean {
      
       @EJB() private Initialization initBean;
       //@EJB private Initialization initBean;
      
      ...
       public String initApplication(){
       initBean.createStock();
       return "enterShop";
       }...
      }


      I tried both versions @EJB() and @EJB.
      But I always get the error:
      18:07:59,000 WARN [WebEJBRemoteHandler] EJBTHREE-1289: Using legacy EjbEncInjector, because mappedName for enc "env/initBean", field "null" is null (container.environmentRefGroup.annotatedEjbReferences = [AnnotatedEJBReferenceMetaData{name=initBean,ejb-ref-type=null,link=null,ignore-dependecy=false,mapped/jndi-name=null,resolved-jndi-name=null,beanInterface=interface de.shop.statelessbeans.Initialization}])
      18:07:59,015 ERROR [TomcatDeployment] ENC setup failed
      java.lang.IllegalStateException: Resolution should not happen via injection container
       at org.jboss.web.tomcat.service.TomcatInjectionContainer.getEjbJndiName(TomcatInjectionContainer.java:621)
       at org.jboss.injection.EjbEncInjector.inject(EjbEncInjector.java:80)
      ...



      I hava one version that works. If I define a RemoteJNDIName for the SessionBean:

      @Stateless
      public class InitializationBean implements Initialization {
      
       public static final String RemoteJNDIName = InitializationBean.class.getSimpleName() + "/remote";
      ...
      



      and call it from the jsf backing Bean with the mappedName-attribute:

      public class ShopBean {
      
       @EJB(mappedName="InitializationBean/remote")
       private Initialization initBean;
      ...
      


      it works. But is this the only and right way to inject the ejb? (Sorry, I am EJB-Beginner)

      Thank you for any hint.
      Nicole

        • 1. Re: @EJB remote access from JSF backing bean, Resolution sho
          jaikiran pai Master

           

          "NSchweig" wrote:


          I use JBoss5 CR2

          18:07:59,000 WARN [WebEJBRemoteHandler] EJBTHREE-1289: Using legacy EjbEncInjector, because mappedName for enc "env/initBean", field "null" is null (container.environmentRefGroup.annotatedEjbReferences = [AnnotatedEJBReferenceMetaData{name=initBean,ejb-ref-type=null,link=null,ignore-dependecy=false,mapped/jndi-name=null,resolved-jndi-name=null,beanInterface=interface de.shop.statelessbeans.Initialization}])
          18:07:59,015 ERROR [TomcatDeployment] ENC setup failed
          java.lang.IllegalStateException: Resolution should not happen via injection container
           at org.jboss.web.tomcat.service.TomcatInjectionContainer.getEjbJndiName(TomcatInjectionContainer.java:621)
           at org.jboss.injection.EjbEncInjector.inject(EjbEncInjector.java:80)
          ...





          I think this issue is related to https://jira.jboss.org/jira/browse/JBAS-5646. That issue has been marked as fixed in CR2. That JIRA talks about fixing the issue in servlets, not sure whether JSF managed beans were considered too.


          • 2. Re: @EJB remote access from JSF backing bean, Resolution sho
            Emanuel Muckenhuber Master

             

            "NSchweig" wrote:

            I use JBoss5 CR2 and I am trying to get access to an ejb from a jsf backing bean.


            Basically it works also with JSF managed beans.
            Are you using an .ear to package your ejb.jar and .war? If so it should work without the mappedName.