3 Replies Latest reply on May 25, 2006 6:22 AM by bhupendra yaduvenshi

    Problem with lookup of EJBs

    Ashwani Sharma Newbie

      Hi,

      I am getting following error while i am trying to lookup ejb.

      Could not dereference object [Root exception is javax.naming.NameNotFoundException: ejb not bound]


      I am using following code for lookup in a Sevlet.

      try {
      Context context = new InitialContext();

      Object ref = context.lookup("java:/comp/env/ejb/MapSession");
      home = (MapSessionHome) PortableRemoteObject.narrow(ref, MapSessionHome.class);
      } catch (Exception e) {
      e.printStackTrace();
      throw new ServletException("look up of java:/comp/env/ejb/MapSession failed",e);
      }


      Following is ejb-jar.xml.


      <enterprise-beans>

      <!-- Session Beans -->
      <session >
      <description><![CDATA[Description for MapSession]]></description>
      <display-name>Name for MapSession</display-name>

      <ejb-name>MapSession</ejb-name>

      <home>com.virtualcityindia.ejbs.MapSessionHome</home>
      <remote>com.virtualcityindia.ejbs.MapSession</remote>
      <ejb-class>com.virtualcityindia.ejbs.MapSessionSession</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </session>

      </enterprise-beans>


      Following is the jboss.xml file:


      <jboss>

      <enterprise-beans>

      <!--
      To add beans that you have deployment descriptor info for, add
      a file to your XDoclet merge directory called jboss-beans.xml that contains
      the <session></session>, <entity></entity> and <message-driven></message-driven>
      markup for those beans.
      -->

      <session>
      <ejb-name>MapSession</ejb-name>
      <invoker>
      <jndi-name>ejb/MapSession</jndi-name>
      </invoker>
      </session>

      <!--
      write a merge file jboss-webservices.ent for webservice-description
      -->

      </enterprise-beans>

      <resource-managers>
      </resource-managers>

      <!--
      | for container settings, you can merge in jboss-container.xml
      | this can contain <invoker-proxy-bindings/> and <container-configurations/>
      -->

      </jboss>


      Following is the jboss-web.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_0.dtd">

      <jboss-web>

      <!-- Resource Environment References -->
      <!--
      For additional resouce-env-ref tags add a merge file called jbossweb-resource-env-ref.xml
      -->

      <!-- Resource references -->
      <!--
      For additional resouce-ref tags add a merge file called jbossweb-resource-ref.xml
      -->

      <!-- EJB References -->
      <!--
      For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml
      -->
      <ejb-ref>
      <ejb-ref-name>ejb/MapSession</ejb-ref-name>
      <jndi-name>ejb/MapSession</jndi-name>
      </ejb-ref>

      <!-- EJB Local References -->
      </jboss-web>


      Following the relevenat portion of web.xml file:

      <web-app>
      <ejb-ref >
      <description><![CDATA[Reference to the MapSession EJB]]></description>
      <ejb-ref-name>ejb/MapSession</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      <home>com.virtualcityindia.interfaces.MapSessionHome</home>
      <remote>com.virtualcityindia.interfaces.MapSession</remote>
      </ejb-ref>

      </web-app>


      When i deploys the ear file to JBoss server: I get following trace:


      18:32:20,228 INFO [EARDeployer] Init J2EE application: file:/C:/Program Files/jboss-4.0.3SP1/server/default/deploy/virtaualcity.ear
      18:32:20,688 INFO [EjbModule] Deploying MapSession
      18:32:20,949 INFO [ProxyFactory] Bound EJB Home 'MapSession' to jndi 'MapSession'
      18:32:20,949 INFO [EJBDeployer] Deployed: file:/C:/Program Files/jboss-4.0.3SP1/server/default/tmp/deploy/tmp56751virtaualcity.ear-contents/webapp.jar
      18:32:21,019 INFO [TomcatDeployer] deploy, ctxPath=/virtualcity, warUrl=.../tmp/deploy/tmp56751virtaualcity.ear-contents/virtualcity-exp.war/
      18:32:21,309 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
      18:32:21,359 INFO [JBossCacheManager] Starting JBossManager
      18:32:21,470 INFO [EARDeployer] Started J2EE application: file:/C:/Program Files/jboss-4.0.3SP1/server/default/deploy/virtaualcity.ear


      It says that EJB is deployed correctly.
      I checked in jmx controller also ... the ejb is deployed correctly.
      But still when i try to look up (Using the code i specified in the start) ; i gets following error:

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception :
      javax.servlet.ServletException: look up of java:/comp/env/ejb/MapSession failed
      com.virtualcityindia.web.IndexServlet.init(IndexServlet.java:60)
      javax.servlet.GenericServlet.init(GenericServlet.java:211)
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:595)


      root cause :
      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ejb not bound]
      org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1052)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      javax.naming.InitialContext.lookup(InitialContext.java:351)
      com.virtualcityindia.web.IndexServlet.init(IndexServlet.java:56)
      javax.servlet.GenericServlet.init(GenericServlet.java:211)
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:595)


      root cause :
      javax.naming.NameNotFoundException: ejb not bound
      org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
      org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
      org.jnp.server.NamingServer.getObject(NamingServer.java:528)
      org.jnp.server.NamingServer.lookup(NamingServer.java:252)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      javax.naming.InitialContext.lookup(InitialContext.java:351)
      org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
      org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
      javax.naming.InitialContext.lookup(InitialContext.java:351)
      com.virtualcityindia.web.IndexServlet.init(IndexServlet.java:56)
      javax.servlet.GenericServlet.init(GenericServlet.java:211)
      org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
      org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      java.lang.Thread.run(Thread.java:595)




      Can somebody pleae reply early. I need to solve this problem as quickly as possible.

      [I tried the same steps as specified in JBoss Fibo example]
      [I am using jboss-4.0.3SP1]


      Thanks in advance,
      Best Regards,
      Ashwani

        • 1. Re: Problem with lookup of EJBs
          VisolveGroup Novice

          Hello,

          In your servlet program, the initial context lookup should be ejb/MapSession instead of java:/comp/env/ejb/MapSession

          Regards,
          Partha

          • 2. Re: Problem with lookup of EJBs
            Ashwani Sharma Newbie

            I get following error when i lookup using "ejb/MapSession"


            13:18:35,445 INFO [STDOUT] javax.naming.NameNotFoundException: ejb not bound
            13:18:35,445 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
            13:18:35,445 INFO [STDOUT] at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
            13:18:35,445 INFO [STDOUT] at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
            13:18:35,445 INFO [STDOUT] at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
            13:18:35,445 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
            13:18:35,445 INFO [STDOUT] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
            13:18:35,445 INFO [STDOUT] at javax.naming.InitialContext.lookup(InitialContext.java:351)
            13:18:35,445 INFO [STDOUT] at com.virtualcityindia.web.IndexServlet.init(IndexServlet.java:56)
            13:18:35,445 INFO [STDOUT] at javax.servlet.GenericServlet.init(GenericServlet.java:211)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            13:18:35,455 INFO [STDOUT] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            13:18:35,455 INFO [STDOUT] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
            13:18:35,455 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
            13:18:35,455 INFO [STDOUT] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            13:18:35,455 INFO [STDOUT] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            13:18:35,455 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            13:18:35,455 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            13:18:35,455 INFO [STDOUT] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            13:18:35,455 INFO [STDOUT] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            13:18:35,455 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)



            THe error is almost same as previuos one.
            I looked into Global JNDI Namespace using jmx-console.
            I found following relevant entried there.

            Looks like MapSession is registered but no class loading available for MapSessionHome.

            Do you have any clue why ?


            +- jmx (class: org.jnp.interfaces.NamingContext)
            | +- invoker (class: org.jnp.interfaces.NamingContext)
            | | +- RMIAdaptor (proxy: $Proxy38 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)
            +- MapSession (proxy: $Proxy58 implements No ClassLoaders found for: com.virtualcityindia.interfaces.MapSessionHome (no security manager: RMI class loader disabled))


            Regards.
            Ashwani

            • 3. Re: Problem with lookup of EJBs
              bhupendra yaduvenshi Newbie

              When u r using first jndi that is genric & in the second this is specific.But both r right.

              this is ur log
              18:32:20,228 INFO [EARDeployer] Init J2EE application: file:/C:/Program Files/jboss-4.0.3SP1/server/default/deploy/virtaualcity.ear
              18:32:20,688 INFO [EjbModule] Deploying MapSession
              18:32:20,949 INFO [ProxyFactory] Bound EJB Home 'MapSession' to jndi 'MapSession'
              18:32:20,949 INFO [EJBDeployer] Deployed: file:/C:/Program Files/jboss-4.0.3SP1/server/default/tmp/deploy/tmp56751virtaualcity.ear-contents/webapp.jar
              18:32:21,019 INFO [TomcatDeployer] deploy, ctxPath=/virtualcity, warUrl=.../tmp/deploy/tmp56751virtaualcity.ear-contents/virtualcity-exp.war/
              18:32:21,309 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
              18:32:21,359 INFO [JBossCacheManager] Starting JBossManager
              18:32:21,470 INFO [EARDeployer] Started J2EE application: file:/C:/Program Files/jboss-4.0.3SP1/server/default/deploy/virtaualcity.ear


              Ok according to that ur jndi name is mapsession not ejb/mapsession that means u r looking a wrong jndi name

              see 18:32:20,949 INFO [ProxyFactory] Bound EJB Home 'MapSession' to jndi 'MapSession'
              here u r binding the wrong jndi name.Just chek it out if that problem is not solve than let me know.

              bhupendra