3 Replies Latest reply on Sep 27, 2004 9:58 AM by imcshane

    ClassLoader problem with a rar inside an ear

    imcshane Newbie

      Hi,

      I have an ear file packaged similarly to the example below which deployes without errors:

      myear/
      ejbs.jar
      servlets.war
      connector.rar
      utils.jar

      where connector.rar contains a jarfile (connector.jar) with my implementation classes.

      The servlets can invoke the ejbs, and the ejbs can invoke the connector.

      My problem is that the classes in connector.jar don't seem to be loaded. When I invoke getConnection() from my EJB my managedconnectionfactory gets invoked but the first time it tries to instantiate a class defined within connector.jar I get a NoClassDefFoundError.

      The top of the stack trace from the error is:
      java.lang.NoClassDefFoundError: com/aepona/causeway/pcp/aepx/resource/common/SessionImpl
      at com.aepona.causeway.pcp.aepx.resource.common.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:74)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:504)
      at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:214)


      I've used the jmx console to check the status of this class and get the following result:
      com.aepona.causeway.pcp.aepx.resource.common.SessionImpl Information
      Not loaded in repository cache

      ### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@44b7f7{ url=file:/tmp/jboss-3.2.5/server/causeway/tmp/deploy/tmp57045aepx-1.0.ear ,addedOrder=35}

      It seems to me that JBoss is aware of the class definition but hasn't loaded it for some reason. I don't understand why it would do this when it has loaded the managed connection factory which is in the same jar file.

      Any help you can provide would be much appreciated.

      Thanks,
      Ivan

      P.S. the same ear works ok in websphere and weblogic. Do jboss classloaders work differently ?

        • 1. Re: ClassLoader problem with a rar inside an ear
          Thierry Janaudy Newbie

          >> P.S. the same ear works ok in websphere and weblogic. Do jboss classloaders work differently ?

          Yes, jBoss ClassLoaders are "different". They have a concept of UnifiedClassLoader that does not exist on Weblogic AFAIK.
          Read this: http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

          • 2. Re: ClassLoader problem with a rar inside an ear
            imcshane Newbie

            Thanks for the reply. If my understanding is correct the wiki is basically stating a jar only needs defined once within an ear file unless there are different version dependencies and it will be loaded into the UnifiedClassLoader. This is the situation with my current app.

            From this console output ...

            com.aepona.causeway.pcp.aepx.resource.common.SessionImpl Information
            Not loaded in repository cache

            ### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@44b7f7{ url=file:/tmp/jboss-3.2.5/server/causeway/tmp/deploy/tmp57045aepx-1.0.ear ,addedOrder=35}


            my class is available to the UCL. I've turned class loader debug on and I can see the jar being added. The console output is as follows:


            09:01:18,004 DEBUG [RARDeployer] Attempting to deploy RAR at 'file:/tmp/jboss-3.2.5/server/causeway/tmp/deploy/tmp64711aepx-1.0.ear-contents/connector-1.0.rar'
            09:01:18,006 DEBUG [RARDeployment] Creating jboss.jca:service=ManagedConnectionFactory,name=connectors/X
            09:01:18,007 DEBUG [JBossManagedConnectionPool] Creating jboss.jca:service=ManagedConnectionPool,name=connectors/X
            09:01:18,008 DEBUG [NoTxConnectionManager] Creating jboss.jca:service=NoTxCM,name=connectors/X
            09:01:18,009 DEBUG [MainDeployer] Done with create step of deploying connector-1.0.rar

            and slightly later in the trace

            09:01:20,257 DEBUG [MainDeployer] Begin deployment start file:/tmp/jboss-3.2.5/server/causeway/tmp/deploy/tmp64711aepx-1.0.ear-contents/connector-1.0.rar
            09:01:20,264 DEBUG [MainDeployer] Begin deployment start file:/tmp/jboss-3.2.5/server/causeway/tmp/deploy/tmp64711aepx-1.0.ear-contents/connector-1.0.rar-contents/connector-1.0.jar
            09:01:20,265 DEBUG [MainDeployer] End deployment start on package: connector-1.0.jar

            I can't see any deployment errors in the log files or console trace.

            So as far as I can tell my class is available in the class loader and there's only one version of it so there should be no conflicts. JBoss won't load it however.

            I've tried various configurations of manifest files, tried moving the connector.jar out into the ear and other options to get this to run but they all throw the same error.

            Are there any known issues accessing a rar deployed within an ear. I should have stated, I'm testing on jboss-3.2.5 on red-hat linux with jdk 1.4.2_01-b06.

            Thanks,
            Ivan


            • 3. Re: ClassLoader problem with a rar inside an ear
              imcshane Newbie

              Just to follow up on this in case anybody has a similar problem. I've got the ear running fine now.

              The error was a bit of a red herring. The problem wasn't that the SessionImpl class wasn't being found but that a 3rd party dependency it relied on was missing so the class couldn't be loaded correctly.