9 Replies Latest reply on Apr 24, 2013 11:13 AM by cchantep

    JNDI (EJB) lookup

      Hi,

       

      I'm trying to migrate an app from JBoss 5.1.0.GA to JBoss 7.1.1.Final. I need to update a service locator class which is JNDI lookup (InitialContext.lookup) to locate session bean. Deployment is done with EAR containing ejb module (myEjbModule after there) and war. In console, I do see session beans deployed (bound?):

       

      java:global/myApp/myEjbModule/my.package.ContentServices!view.ContentServices
      java:app/myEjbModule/my.package.ContentServices!view.ContentServices
      java:module/my.package.ContentServices!view.ContentServices
      java:jboss/exported/myApp/myEjbModule/my.package.ContentServices!view.ContentServices
      java:global/myApp/myEjbModule/my.package.ContentServices
      java:app/myEjbModule/my.package.ContentServices
      java:module/my.package.ContentServices

       

      myApp being the application name defined in application.xml of .ear file.

       

      But when webapp class try to get session bean throught the locator, I got lookup failure. I've tried lot of naming combination (java:global/..., java:app/..., java:module/..., ejb:/global/..., …).

       

      I see forum topic about accessing EJB through lookup from remote client, but that's unclear to me how to successfully do that within same container/same app, as long as I would really prefer a compatibility solution rather than large refactoring.

       

      Session bean implementation is annotated like following:

       

      @javax.ejb.Stateless(name = "my.package.ContentServices")
      @javax.ejb.Remote({view.ContentServices.class})
      @javax.ejb.TransactionAttribute(javax.ejb.TransactionAttributeType.REQUIRED)

       

      Any help would be welcomed, thanks in advance.

        • 1. Re: JNDI (EJB) lookup
          jaikiran

          Please post the entire exception stacktrace and the code which is looking it up.

          • 2. Re: JNDI (EJB) lookup
            sfcoy

            Please show the code for your locator, as well as the error messages that you're seeing.

            • 3. Re: JNDI (EJB) lookup
              InitialContext ctx = new InitialContext();

              ctx.lookup(jndiName); // jndiName one of tried binding name

              Error is:

              java.lang.IllegalStateException: No EJB receiver available for handling [appName:global,modulename:org.ffmoto.portal,distinctname:ffmoto-services] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@7e01eda4
                  at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) [jboss-ejb-client-1.0.5.Final.jar:1.0.5.Final]
                  at com.sun.proxy.$Proxy61.getUser(Unknown Source)
                  at fr.corsaire.siville.web.ContextListener.contextInitialized(ContextListener.java:53)
              • 4. Re: JNDI (EJB) lookup
                sfcoy

                I would expect that to work.

                 

                You haven't got a jndi.properties file lying around in your application by any chance? That could cause this problem.

                • 5. Re: JNDI (EJB) lookup

                  Nope.

                  • 6. Re: JNDI (EJB) lookup
                    sfcoy

                    Do you have jboss-ejb-client-1.0.5.Final.jar in your WAR or EAR?

                     

                    If so, remove it.

                    • 7. Re: JNDI (EJB) lookup

                      I don't have such jar anywhere.

                      • 8. Re: JNDI (EJB) lookup
                        sfcoy
                        • 9. Re: JNDI (EJB) lookup

                          Thanks for your help. It seems EJB were deployed as 2.1, and it silently raise some binding issue.