4 Replies Latest reply on Aug 4, 2003 5:17 PM by Robert Costanzo

    jboss-3.2.1_tomcat-4.1.24 Servlet to Local Session EJB socke

    Robert Costanzo Newbie

      Hi all,

      I have an application in an EAR which has been working without issue for me on the default distribution of Jboss 3.2.1 with Jetty. I'm trying to switch over to Tomcat using the bundled jboss 3.2.1 / Tomcat 4.1.24 distribution. However, my EAR which works fine with Jetty is getting the following error with Tomcat when looking up a Stateless Session EJB's Local Home from a servlet:

      [java] javax.naming.CommunicationException: Receive timed out. Root exception is
      [java] java.net.SocketTimeoutException: Receive timed out
      [java] at java.net.PlainDatagramSocketImpl.receive(Native Method)
      [java] at java.net.DatagramSocket.receive(DatagramSocket.java:680)
      [java] at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1038
      )
      [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1158)
      [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:478)
      etc....


      My EAR is packaged as follows:
      MyEAR.ear
      MyWebApp.war
      -- Contains servlet classes
      MyEJBs.jar
      -- Contains all Session EJB Facade classes
      -- Contains all Session EJB interfaces


      Note that I have unit tests which access the EJBs directly from a remote JVM using the remotes and they all run fine.

      The code I use to do the actual lookup to the session EJBs from the facade is XDoclet generated:

      InitialContext initialContext = new InitialContext();
      cachedLocalHome = (mts.psp.ui.SessionManagerLocalHome) initialContext.lookup(local/mts.psp.ui.SessionManager);

      Note that I'm using the physical JNDI name and not the logical java:comp/env/ejb/... one.

      Is there something I'm missing to get Tomcat to access an EJB local home? I'm not using any of the ejb-ref-local or ejb-ref tags in the web.xml and jboss-web.xml, but that wasn't necessary for Jetty. What strikes me is the fact that the exception is for a socket timeout, which if it's using a local EJB should there really be any sockets being opened?

      Any insight into this issue would be greatly appreciated.

        • 1. Re: jboss-3.2.1_tomcat-4.1.24 Servlet to Local Session EJB s
          Adrian Brock Master

          Sounds like you have a jndi.properties somewhere in the
          deployment?

          Regards,
          Adrian

          • 2. Re: jboss-3.2.1_tomcat-4.1.24 Servlet to Local Session EJB s
            Robert Costanzo Newbie

            My jndi.properties is the default. I've tracked down the exception through the source code and what's happening is as follows:

            The local naming class variable, which gets set when the jnp service is started through the method NamingContext.setLocal, is null for some reason. This is causing the NamingContext to do a broadcast to search for the server to do the lookup on. This is what is timing out.

            I believe that for some reason it is not finding its local jnp instance which is supposed to be defined when the jnp server starts up (which is happening properly I verified in my log file). I need to find out why that variable is not being set. My best guess now is that the class is available in multiple classloaders and the wrong one is being accessed. I'm going to see if any other NamingContext classes are available in any of the jars included in my WAR.

            • 3. Re: jboss-3.2.1_tomcat-4.1.24 Servlet to Local Session EJB s
              Robert Costanzo Newbie

              Here's what I've found:

              When the local server gets set in the Naming Context (a static method call), if I print out the classloader it's the UnifiedClassLoader.

              However, when I go to access the local homes and it's in the lookup method, the local server is null and the classloader is the WebappClassLoader.

              What's odd is I checked all of the jars under my server directory and the only jar which contains the NamingContext class is in server/default/lib/jnpserver.jar

              So is there anything obviously wrong with my EAR that would cause Tomcat to be using its own classloader and "copy into it" a class from the UnifiedClassLoader? Also, the parent of the WebAppClassLoader is java.net.FactoryURLClassLoader and NOT the UnifiedClassLoader as I would expect.

              • 4. Re: jboss-3.2.1_tomcat-4.1.24 Servlet to Local Session EJB s
                Robert Costanzo Newbie

                I printed out all of the classloader info I could get using the nice debug util included in the jboss examples. When not accessing EJBs through Tomcat the NamingContext class's loader details looks like:


                [java] org.jnp.interfaces.NamingContext(10bbf9e).ClassLoader=org.jboss.mx.loading.Unif
                iedClassLoader3@12611a7{ url=file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/
                server/default/conf/jboss-service.xml/1.jboss-service.xml ,addedOrder=2}
                [java] ..org.jboss.mx.loading.UnifiedClassLoader3@12611a7{ url=file:/C:/jboss-3.2.1_to
                mcat-4.1.24/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-servic
                e.xml ,addedOrder=2}
                [java] ..org.jboss.system.server.NoAnnotationURLClassLoader@e53108
                [java] ..sun.misc.Launcher$AppClassLoader@12f6684
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/bin/run.jar
                [java] ....file:/C:/j2sdk1.4.1_03/lib/tools.jar
                [java] ..sun.misc.Launcher$ExtClassLoader@f38798
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/dnsns.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/ldapsec.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/localedata.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/sunjce_provider.jar
                [java] ++++CodeSource: (file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/lib/jnpserve
                r.jar <no certificates>)
                [java] Implemented Interfaces:
                [java] ++interface javax.naming.Context(513d61)
                [java] ++++ClassLoader: null
                [java] ++++Null CodeSource
                [java] ++interface java.io.Serializable(19e8329)
                [java] ++++ClassLoader: null
                [java] ++++Null CodeSource



                When accessing it (indirectly) through Tomcat by looking up the local home, it looks like:



                [java] org.jnp.interfaces.NamingContext(4e18d4).ClassLoader=WebappClassLoader
                [java] available:
                [java] Extension[javax.activation, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.0.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.0]
                [java] Extension[org.apache.commons.beanutils, implementationVendor=Apache Software Foundation, implementationVersion=1.4-dev, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation,
                specificationVersion=2.1]
                [java] Extension[org.apache.commons.digester, implementationVendor=Apache Software Foundation, implementationVersion=1.3, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[org.apache.commons.validator, implementationVendor=Apache Software Foundation, implementationVersion=1.0.1, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[Struts Framework, implementationVendor=Apache Software Foundation, implementationVendorId=org.apache, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=1.1]
                [java] delegate: false
                [java] repositories:
                [java] /WEB-INF/classes/
                [java] required:
                [java] ----------> Parent Classloader:
                [java] java.net.FactoryURLClassLoader@13c6a8b
                [java]
                [java] ..WebappClassLoader
                [java] available:
                [java] Extension[javax.activation, implementationVendor=Sun Microsystems, Inc., implementationVendorId=com.sun, implementationVersion=1.0.2, specificationVendor=Sun Microsystems, Inc., specificationVersion=1.0]
                [java] Extension[org.apache.commons.beanutils, implementationVendor=Apache Software Foundation, implementationVersion=1.4-dev, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[org.apache.commons.collections, implementationVendor=Apache Software Foundation, implementationVersion=2.1, specificationVendor=Apache Software Foundation, specificationVersion=2.1]
                [java] Extension[org.apache.commons.digester, implementationVendor=Apache Software Foundation, implementationVersion=1.3, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[org.apache.commons.validator, implementationVendor=Apache Software Foundation, implementationVersion=1.0.1, specificationVendor=Apache Software Foundation, specificationVersion=1.0]
                [java] Extension[Struts Framework, implementationVendor=Apache Software Foundation, implementationVendorId=org.apache, implementationVersion=1.1, specificationVendor=Apache Software Foundation, specificationVersion=1.1]
                [java] delegate: false
                [java] repositories:
                [java] /WEB-INF/classes/
                [java] required:
                [java] ----------> Parent Classloader:
                [java] java.net.FactoryURLClassLoader@13c6a8b
                [java]
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/work/MainEngine/localhost/psp/WEB-INF/classes/
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/work/MainEngine/localhost/psp/WEB-INF/lib/BlowfishJ-2.0.2.jar
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/work/MainEngine/localhost/psp/WEB-INF/lib/PSP-V2-COMMON-CURRENT.jar
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/work/MainEngine/localhost/psp/WEB-INF/lib/PSP-V2-DATAPASS-CURRENT.jar
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/work/MainEngine/localhost/psp/WEB-INF/lib/activation-1.0.2.jar
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/mail-service.xml/33.mail-service.xml
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/lib/jboss-jsr77.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/localedata.jar
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/jbossweb-tomcat.sa
                r/
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/lib/jboss-jaas.jar
                [java] ..java.net.FactoryURLClassLoader@13c6a8b
                [java] ..org.jboss.mx.loading.UnifiedClassLoader3@1a1ff9{ url=file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/deploy/PSP.ear/ ,addedOrder=24}
                [java] ..org.jboss.mx.loading.HeirarchicalLoaderRepository3$NoParentClassLoader@8d1800

                [java] ..sun.misc.Launcher$AppClassLoader@12f6684
                [java] ....file:/C:/jboss-3.2.1_tomcat-4.1.24/bin/run.jar
                [java] ....file:/C:/j2sdk1.4.1_03/lib/tools.jar
                [java] ..sun.misc.Launcher$ExtClassLoader@f38798
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/dnsns.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/ldapsec.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/localedata.jar
                [java] ....file:/C:/j2sdk1.4.1_03/jre/lib/ext/sunjce_provider.jar
                [java] ++++CodeSource: (file:/C:/jboss-3.2.1_tomcat-4.1.24/server/default/lib/jnpserve
                r.jar <no certificates>)
                [java] Implemented Interfaces:
                [java] ++interface javax.naming.Context(513d61)
                [java] ++++ClassLoader: null
                [java] ++++Null CodeSource
                [java] ++interface java.io.Serializable(19e8329)
                [java] ++++ClassLoader: null
                [java] ++++Null CodeSource
                [java] 18:03:29,135 ERROR [STDERR]



                So when going through Tomcat's classloader it has EVERYTHING in it. When not it's very clean. Another interesting note is when I switch back to Jetty, the classloader info looked exactly like the first one even when accessing it through the webapp. Does Jetty not create a child WebAppClassLoader like Tomcat?

                Hopefully somebody has seen something like this before and can make some sense of it for me. Thanks.