5 Replies Latest reply on Jun 27, 2007 10:57 AM by pmadhum

    JNDI Look up in JBoss 4.0.5GA

    pmadhum

      Hi,
      I am migrating the application from Jboss 3.2.8 to Jboss4.0.5GA.
      I can deploy the ear file successfully in Jboss4.0.5 and all beans deployed correctly. Global JNDI Names space looks like this. I can run the application in Jboss 3.2.8, but not in jboss 4.0.5 getting error,while looking up session bean.
      ----------------------------
      javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]]
      ----------------------------------------------
      the lookup code is, below worked in jboss 3.2 but getting above error in jboss 4.0.5GA, Can you please help me with the problem.?
      --------------------------
      InitialContext ictx = new InitialContext();
      ictx.lookup("java:comp/env/ejb/SessionMaterial")
      -------------------------------------------
      --------------------------
      Global JNDI Namespace
      +- MaterialLocal (proxy: $Proxy63 implements interface com.skandia.model.entity.material.MaterialLocalHome)
      +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
      +- jmx (class: org.jnp.interfaces.NamingContext)
      | +- invoker (class: org.jnp.interfaces.NamingContext)
      | | +- RMIAdaptor (proxy: $Proxy42 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)
      +- ZugangLocal (proxy: $Proxy62 implements interface com.skandia.model.entity.zugang.ZugangLocalHome)
      +- BestellungLocal (proxy: $Proxy65 implements interface com.skandia.model.entity.bestellung.BestellungLocalHome)
      +- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- MaterialversionLocal (proxy: $Proxy66 implements interface com.skandia.model.entity.materialversion.MaterialversionLocalHome)
      +- UserTransactionSessionFactory (proxy: $Proxy12 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
      +- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
      +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
      +- 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: $Proxy43 implements interface org.jboss.console.manager.PluginManagerMBean)
      +- LagerbestandLocal (proxy: $Proxy64 implements interface com.skandia.model.entity.lagerbestand.LagerbestandLocalHome)
      +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      +- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
      +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      +- ejb (class: org.jnp.interfaces.NamingContext)
      | +- SessionMaterial (proxy: $Proxy76 implements interface com.skandia.model.session.material.SessionMaterialHome,interface javax.ejb.Handle)
      | +- SessionCodes (proxy: $Proxy74 implements interface com.skandia.model.session.codes.SessionCodesHome,interface javax.ejb.Handle)
      +- AbgangLocal (proxy: $Proxy67 implements interface com.skandia.model.entity.abgang.AbgangLocalHome)
      +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
      +- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)
      ------------------------------------------


        • 1. Re: JNDI Look up in JBoss 4.0.5GA
          itsme

          hi,

          first check if the server is up and running and try the following

          Context ctx = new InitialContext();
          ctx.loopup("MaterialLocal");
          


          • 2. Re: JNDI Look up in JBoss 4.0.5GA
            pmadhum

            I am not able to lookup this bean,
            ----------------
            ictx = new InitialContext();
            ictx.lookup("java:comp/env/ejb/MaterialLocal");
            ----------------
            this was working in jboss3.2.8, and now getting error
            --------
            javax.naming.NameNotFoundException: MaterialLocal not bound
            cannot find object: java:comp/env/ejb/MaterialLocal
            --------
            and i tried to lookup also "java:comp/env/MaterialLocal", but did not work.

            • 3. Re: JNDI Look up in JBoss 4.0.5GA
              itsme

              as your jndiView states different local interfaces should be located right in the GlobalNameSpace. So they should be looked up via

              new InitialContext().lookup(<InterfaceName>);
              .
              Besides that there are some ejb's bound to ejb/, so ejb/ should be used for lookup code.

              As far as I can see from your JndiTrace it should be possible to retrieve the home interface like this (i.e. for SessionMaterial found here

              +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
              +- ejb (class: org.jnp.interfaces.NamingContext)
              | +- SessionMaterial (proxy: $Proxy76 implements interface com.skandia.model.session.material.SessionMaterialHome,interface javax.ejb.Handle)
              | +- SessionCodes (proxy: $Proxy74 implements interface com.skandia.model.session.codes.SessionCodesHome,interface javax.ejb.Handle)

              ...
              Object obj = ictx.loopup("ejb/SessionMaterial");
              SessionMaterialHome home = PortableRemoteObject.narrow(obj, SessionMaterialHome.class);
              SessionMaterial ejb = home.create();
              ...
              


              • 4. Re: JNDI Look up in JBoss 4.0.5GA
                pmadhum

                Hi,
                I am using below code for getting the Homeinterface of session bean SessionMaterial as follows
                (Same as you mentioned in the code, but looking for "java:comp/env/ejb/SessionMaterial") this same code was working in jboss 3.2.8.
                --------------------------------------------------------------------
                Object obj = ictx.lookup("java:comp/env/ejb/SessionMaterial");
                return PortableRemoteObject.narrow(obj, SessionMaterialHome.class);
                --------------------------------------------------------------
                Now getting
                ----------
                javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.CommunicationException: Receive timed out
                ----------

                when i changed to look for only "ejb/SessionMaterial", getting below error
                ----
                ava.lang.LinkageError: loader constraints violated when linking javax/ejb/Handle class
                at java.lang.Class.getDeclaredFields0(Native Method)
                at java.lang.Class.privateGetDeclaredFields(Class.java:2232)
                at java.lang.Class.getDeclaredField(Class.java:1852)
                at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1555)
                at java.io.ObjectStreamClass.access$600(ObjectStreamClass.java:47)
                at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:381)
                at java.security.AccessController.doPrivileged(Native Method)
                at java.io.ObjectStreamClass.(ObjectStreamClass.java:373)
                at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)
                at java.io.ObjectStreamClass.initProxy(ObjectStreamClass.java:464)
                at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1502)
                ----

                • 5. Re: JNDI Look up in JBoss 4.0.5GA
                  pmadhum

                  Hi,
                  I have solved this issue, the solution is changing the file jboss-service.xml under 'server\default\deploy\jbossweb-tomcat50.sar\META-INF', in this make the property 'Java2ClassLoadingCompliance' to true.
                  This will solve the problem when you are migratining 3.x to 4.x and ejbs are throwing errors like could not dereference object.

                  Madhu