4 Replies Latest reply on Sep 19, 2002 11:38 AM by chansen

    JBoss3.0.0+Tomcat4.0.3 ClassLoader intermingling between app

    chansen

      We're finding that, in some cases, JBoss3.0.0+Tomcat4.0.3 is not preserving separation of ClassLoaders between separate applications. We wanted to know if anyone else has encountered this problem.

      We have two unrelated ears which both contain wars. Third party ear A contains struts.jar and war A within ear A contains a MANIFEST.MF which contains a ClassPath which refers to struts.jar. Ear B contains war B with struts.jar in WEB-INF/lib.

      These apps *should* not share any classes. However, when we run app B, it uses app A's struts.jar. Furthermore, app A's struts.jar cannot load app B's classes.

      We worked around the problem by changing the third party ear A to store jars in WEB-INF/lib rather than refer to them in the MANIFEST.

      It is my understanding that JBoss 3.0 does not support MANIFEST ClassPath entries in a war. If that's the case, wouldn't those jars be ignored altogether? It seems dangerous to breach the barrier between applications' classloaders.

      Any information would be appreciated. Thanks!

      - Chris

        • 1. Re: JBoss3.0.0+Tomcat4.0.3 ClassLoader intermingling between

          You can override this sharing behavior with jboss-app.xml. See this FAQ for more details: http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/

          • 2. Re: JBoss3.0.0+Tomcat4.0.3 ClassLoader intermingling between
            chansen

            Juha -

            Thanks for the info. We were able to use the jboss-app.xml deployment descriptor to separate the Unified Repository as it described.
            Having the apps separate yields another problem, though. App A makes EJB calls to App B. We add App B's EJB interfaces and homes to ear A. In a web app in app A, a lookup of the home succeeds but the narrow throws a CastClassException. Note that we have not hot deployed, so this is not the same problems as described in thread
            http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ Proxy returned by the lookup is from App B's UnifiedClassLoader. It appears that, despite the separation of app Unified Repositories, JBoss has one shared JNDI namespace with Proxy classes loaded from different Repositories. I would have expected/hoped that JBoss would create and bind a seperate Proxy for App A so that App A could look up an EJBHome in another app and the cast would succeed.

            So, for apps that use different class Repositories (i.e. configured to be compliant with the J2EE), what is the best way to call an EJB between apps? We tried adding a jndi-name entry with a jnp URI to the jboss-web.xml, but that had no effect.

            Do we have to configure jndi.properties to always use JNP? That would have the undesirable side-effect of forcing even intra-app EJB calls to go through the JNP server.

            Thanks in advance.

            - Chris Hansen

            • 3. Re: JBoss3.0.0+Tomcat4.0.3 ClassLoader intermingling between

              Does the lookup fail if you don't use PRO.narrow() on the home proxy?

              • 4. Re: JBoss3.0.0+Tomcat4.0.3 ClassLoader intermingling between
                chansen

                The lookup is before the narrow. The lookup succeeds regardless. It's the narrow that fails. We tried replacing the narrow with a simple cast but that also fails with a ClassCastException.

                We worked around the problem by combining the two applications into one ear. But I don't think that that workaround is always acceptable, so we're still curious if there's a way to communicate between apps with different repositories on the same server.