13 Replies Latest reply on Oct 16, 2012 7:46 AM by nik...

    JBoss 4.2 ejb not bound

    _steph

      Hi,

      My JEE app contains a simple ejb session. When I deploy the EAR on JBoss the console says:

      [EjbModule] Deploying Calc
      00:46:30,578 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Calc' to jndi 'env/ejb/CalcLocalHome'
      00:46:30,578 INFO [ProxyFactory] Bound EJB Home 'Calc' to jndi 'env/ejb/CalcHome'

      But when I try a lookup I get an ejb not bound exception. And my ejb is not listed in the JNDiView:

      Ejb Module: Calc.jar

      java:comp namespace of the Calc bean:

      +- env



      So, it is not bind. I do not understand.

      Could someone help please?

      Stephane

        • 1. Re: JBoss 4.2 ejb not bound
          jaikiran

          Without looking at your configuration files and the EJB/lookup code, i am just guessing that your bean is bound to the Global JNDI namespace, by the jndi name "env/ejb/CalcHome" (the remote home) and "env/ejb/CalcLocalHome" (for the local home). So if you are looking up the remote interface then your lookup code should look like:


          Context ctx = new InitialContext();
          //remote bean lookup
          Object obj = ctx.lookup("env/ejb/CalcHome");
          CalcHome home = (CalcHome) PortableRemoteObject.narrow(obj,CalcHome.class);
          //create the remote bean
          bean = home.create();



          • 2. Re: JBoss 4.2 ejb not bound
            _steph

            Thank you for your reply Jaikiran.


            Configuration files and lookup code are generated with Xdoclet 1.2.3.

            Bean Xdoclet tags:

            * @ejb.bean name="Calc" description="An EJB named Calc" display-name="Calc"
            * view-type="both" jndi-name="CalcHome" local-jndi-name =
            * "CalcLocalHome" type="Stateless" transaction-type="Container"
            *
            *
            * @ejb.util generate="logical"
            *
            * @ejb.home package="calc.interfaces"
            *
            *

            generated ejb-jar.xml file:

            <display-name>Calc</display-name>

            <enterprise-beans>

            <!-- Session Beans -->

            <![CDATA[An EJB named Calc]]>
            <display-name>Calc</display-name>

            <ejb-name>Calc</ejb-name>

            calc.interfaces.CalcHome
            calc.ejb.Calc
            <local-home>calc.interfaces.CalcLocalHome</local-home>
            calc.ejb.CalcLocal
            <ejb-class>calc.ejb.CalcSession</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>


            ...

            </ejb-jar>



            jboss.xml specific generated file:



            <enterprise-beans>




            <ejb-name>Calc</ejb-name>
            <jndi-name>CalcHome</jndi-name>
            <local-jndi-name>CalcLocalHome</local-jndi-name>

            <method-attributes>
            </method-attributes>




            Server log when I deploy the app:


            02:52:21,796 INFO [EARDeployer] Init J2EE application: file:/D:/jboss-4.2.0/server/default/deploy/CalcEAR.ear
            02:52:22,015 INFO [EjbModule] Deploying Calc
            02:52:22,390 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Calc' to jndi 'CalcLocalHome'
            02:52:22,406 INFO [ProxyFactory] Bound EJB Home 'Calc' to jndi 'CalcHome'

            02:52:22,406 INFO [EJBDeployer] Deployed: file:/D:/jboss-4.2.0/server/default/tmp/deploy/tmp27268CalcEAR.ear-contents/Calc.jar
            02:52:22,421 INFO [TomcatDeployer] deploy, ctxPath=/CalcWeb, warUrl=.../tmp/deploy/tmp27268CalcEAR.ear-contents/CalcWeb-exp.war/
            02:52:22,515 INFO [EARDeployer] Started J2EE application: file:/D:/jboss-4.2.0/server/default/deploy/CalcEAR.ear



            So the session bean is supposed to be bound to jndi his names.
            But in the JNDIView.list() result there is no Calc bean. It's not deployed

            ...
            Ejb Module: Calc.jar

            java:comp namespace of the Calc bean:

            +- env (class: org.jnp.interfaces.NamingContext)
            ...

            For me it's a jboss bug and the jboss log is erroneous. The lookup code generated by Xdoclet too, I tried your sample lookup code with same result.

            Stephane.




            • 3. Re: JBoss 4.2 ejb not bound
              jaikiran

               

              <jndi-name>CalcHome</jndi-name>
              <local-jndi-name>CalcLocalHome</local-jndi-name>
              


              02:52:22,390 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Calc' to jndi 'CalcLocalHome'
              02:52:22,406 INFO [ProxyFactory] Bound EJB Home 'Calc' to jndi 'CalcHome'


              Your EJB is deployed and bound to the JNDI name CalcHome for the remote interface and CalcLocalHome for the local interface in the *global jndi namespace*.

              So your lookup should look like:

              Context ctx = new InitialContext();
              //remote home lookup
              Object obj = ctx.lookup("CalcHome");
              CalcHome home = (CalcHome) PortableRemoteObject.narrow(obj,CalcHome.class);
              //create the remote bean
              bean = home.create();
              

              For local interface

              Context ctx = new InitialContext();
              //local home lookup
              Object obj = ctx.lookup("CalcLocalHome");
              CalcLocalHome localhome = (CalcLocalHome) obj;
              //create the local bean
              bean = localhome.create();
              


              • 4. Re: JBoss 4.2 ejb not bound
                _steph


                My lookup is generated by Xdoclet and is correct.
                But anyway the bean should be listed in the JndiVew of the JBoss Console and it is not. I don't know why.

                • 5. Re: JBoss 4.2 ejb not bound
                  _steph


                  I mean that the bean is not deployed. I do not know why.

                  • 6. Re: JBoss 4.2 ejb not bound
                    jaikiran

                    Going by the log messages that you posted, i am confident that the bean is being deployed. You are looking in the wrong jndi namespace for your bean. Do the following:

                    - Go to http://localhost:8080/jmx-console
                    - On the page that comes up, search for service=JNDIView
                    - Click on that
                    - On the page that comes up click on the Invoke button beside the list() method
                    - The next page will contain the JNDI tree view. Post it here. You will find your bean under the "Global JNDI namespace" on that page.

                    • 7. Re: JBoss 4.2 ejb not bound
                      _steph

                      Hello,

                      I have been abroad and away from this forum for 3 weeks.
                      Here is the result of the JNDIView.list():

                      Web Applications

                      java:comp namespace of the jbossws.sar/jbossws-context.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                      java:comp namespace of the http-invoker.sar/invoker.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/jmx-console/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/jmx-console] (class: javax.naming.LinkRef)


                      java:comp namespace of the jboss-web.deployer/ROOT.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                      java:comp namespace of the CalcEAR.ear/CalcWeb.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                      java:comp namespace of the jbossmq-httpil.sar/jbossmq-httpil.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/jbossmq/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/jbossmq] (class: javax.naming.LinkRef)


                      java:comp namespace of the console-mgr.sar/web-console.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                      java:comp namespace of the jmx-console.war application:

                      +- UserTransaction[link -> UserTransaction] (class: javax.naming.LinkRef)
                      +- env (class: org.jnp.interfaces.NamingContext)
                      | +- security (class: org.jnp.interfaces.NamingContext)
                      | | +- realmMapping[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- subject[link -> java:/jaas/other/subject] (class: javax.naming.LinkRef)
                      | | +- securityMgr[link -> java:/jaas/other] (class: javax.naming.LinkRef)
                      | | +- security-domain[link -> java:/jaas/other] (class: javax.naming.LinkRef)


                      Ejb Module: Calc.jar

                      java:comp namespace of the Calc bean:

                      +- env (class: org.jnp.interfaces.NamingContext)


                      java: Namespace

                      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                      +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
                      +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
                      +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
                      +- comp (class: javax.naming.Context)
                      +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
                      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                      +- jaas (class: javax.naming.Context)
                      | +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
                      | +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
                      | +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
                      +- comp.original (class: javax.namingMain.Context)
                      +- timedCacheFactory (class: javax.naming.Context)
                      Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy cannot be cast to javax.naming.NamingEnumeration
                      +- TransactionPropagationContextExporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                      +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
                      +- Mail (class: javax.mail.Session)
                      +- comp.ejb3 (class: javax.naming.Context)
                      | NonContext: null
                      +- TransactionPropagationContextImporter (class: com.arjuna.ats.internal.jbossatx.jta.PropagationContextManager)
                      +- TransactionManager (class: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate)


                      Global JNDI Namespace

                      +- CalcHome (proxy: $Proxy85 implements interface calc.interfaces.CalcHome,interface javax.ejb.Handle)
                      +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
                      +- jmx (class: org.jnp.interfaces.NamingContext)
                      | +- invoker (class: org.jnp.interfaces.NamingContext)
                      | | +- RMIAdaptor (proxy: $Proxy48 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
                      | +- rmi (class: org.jnp.interfaces.NamingContext)
                      | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
                      +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                      +- Stateless (class: org.jnp.interfaces.NamingContext)
                      | +- GeometricModelBean (class: org.jnp.interfaces.NamingContext)
                      +- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
                      +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
                      +- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
                      +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
                      +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
                      +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
                      +- queue (class: org.jnp.interfaces.NamingContext)
                      | +- A (class: org.jboss.mq.SpyQueue)
                      | +- testQueue (class: org.jboss.mq.SpyQueue)
                      | +- ex (class: org.jboss.mq.SpyQueue)
                      | +- DLQ (class: org.jboss.mq.SpyQueue)
                      | +- D (class: org.jboss.mq.SpyQueue)
                      | +- C (class: org.jboss.mq.SpyQueue)
                      | +- B (class: org.jboss.mq.SpyQueue)
                      +- topic (class: org.jnp.interfaces.NamingContext)
                      | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
                      | +- testTopic (class: org.jboss.mq.SpyTopic)
                      | +- securedTopic (class: org.jboss.mq.SpyTopic)
                      +- console (class: org.jnp.interfaces.NamingContext)
                      | +- PluginManager (proxy: $Proxy49 implements interface org.jboss.console.manager.PluginManagerMBean)
                      +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
                      +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
                      +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
                      +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
                      +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
                      +- CalcLocalHome (proxy: $Proxy83 implements interface calc.interfaces.CalcLocalHome)



                      The only trace of deployement is:

                      Ejb Module: Calc.jar

                      java:comp namespace of the Calc bean:

                      +- env (class: org.jnp.interfaces.NamingContext)

                      It does not seem to be correct.

                      • 8. Re: JBoss 4.2 ejb not bound
                        _steph

                        There is this in the log:

                        21:21:42,578 ERROR [[jsp]] "Servlet.service()" pour la servlet jsp a généré une exception
                        javax.naming.NameNotFoundException: ejb not bound
                        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                        at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                        at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                        at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                        at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
                        at o...

                        Does it meen that the lookup is done on something like "ejb" and not CalcHome?

                        • 9. Re: JBoss 4.2 ejb not bound
                          jaikiran

                           

                          +- CalcHome (proxy: $Proxy85 implements interface calc.interfaces.CalcHome,interface javax.ejb.Handle)


                          The JNDI view that you posted shows that your EJB has been bound with the jndi name CalcHome in the global jndi namespace. So your lookup should be like:

                          ctx.lookup("CalcHome");


                          javax.naming.NameNotFoundException: ejb not bound
                          at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
                          at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
                          at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
                          at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
                          at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
                          at o...

                          Does it meen that the lookup is done on something like "ejb" and not CalcHome?


                          Yes, it means that the lookup code is using the jndi name which contains "ejb" as part of the lookup string (which is wrong because the lookup string should be "CalcHome")



                          • 10. Re: JBoss 4.2 ejb not bound
                            _steph


                            In debug mode I verified that the InitialContext.lookUp(..) is done on "java:comp/env/ejb/Calc" it's correct and it seems to confirm that the ejb is not deployed correctly. I do not understand why.

                            • 11. Re: JBoss 4.2 ejb not bound
                              jaikiran

                               

                              In debug mode I verified that the InitialContext.lookUp(..) is done on "java:comp/env/ejb/Calc" it's correct and it seems to confirm that the ejb is not deployed correctly.


                              _steph, As we already saw in the JNDI tree view that you posted, then bean is not bound by java:comp/env/ejb/Calc. So using that name in the lookup is incorrect. But i think i understand what you are saying, you want to continue using that lookup string and be able to successfully lookup the bean. Is that correct? If yes, then you will have to modify the web.xml and jboss-web.xml to include the following (in addition to what you already have in them)

                              web.xml:

                              <web-app>
                              ...... all your existing stuff here
                              <ejb-ref>
                               <ejb-ref-name>ejb/Calc</ejb-ref-name>
                               <ejb-ref-type>Session</ejb-ref-type>
                               <home>calc.interfaces.CalcHome</home>
                               <remote>calc.ejb.Calc</remote>
                               </ejb-ref>
                              </web-app>
                              


                              jboss-web.xml:


                              <jboss-web>
                              ...all your existing stuff here
                              <ejb-ref>
                               <ejb-ref-name>ejb/Calc</ejb-ref-name>
                               <jndi-name>CalcHome</jndi-name>
                               </ejb-ref>
                              </jboss-web>
                              


                              Once you add these to your web.xml and jboss-web.xml, you will be able to lookup the bean using java:comp/env/ejb/Calc. This lookup string is going to return you the remote interface of your bean.





                              • 12. Re: JBoss 4.2 ejb not bound
                                jaikiran

                                And please restart the server after these changes.

                                • 13. Re: JBoss 4.2 ejb not bound
                                  nik...

                                  Hi jaikiran,

                                  How can I change my auto generated interface to search bean in global jndi name space.