5 Replies Latest reply on Jan 23, 2006 6:40 AM by Maximiliano Sanchez de Bustamante

    Failure in Isolation with Overriding over jboss-4.0.3

    Maximiliano Sanchez de Bustamante Newbie

      Hi.
      I work a year with the version 4.0.1 without problems. The application run well in other two flavors of application server (obviously with the corresponding specific configuration files and the specific implementation of out services).
      I try to migrate from 4.0.1 to 4.0.3SP1 and found a problem with ClassLoaders. I read the documentation of the changes in 4.0.2 of the class loading mechanism. I need my ear totally isolated. But, in spite of the read of wikipedia (http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration and
      http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClassLoadingUseCases) I detect that the application use de library dom4j.jar of {jboss.home}/lib instead of the library inside my ear. The application throws an exception because the dom4j library in the ear contains ?xpath? module and the library provide by jboss not.

      09:11:18,204 ERROR [[CLTest]] Servlet.service() for servlet CLTest threw exception
      java.lang.NoClassDefFoundError: org/dom4j/xpath/DefaultXPath
       at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
       at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207)
       at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164)
       at ar.com.sif.services.MenuLoader.loadXml(MenuLoader.java:77)
       at ar.com.sif.test.CLTestServlet.doGet(CLTestServlet.java:89)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:534)
      


      The class org.dom4j.DocumentFactory, found in both libraries call the class org.dom4j.xpath.DefaultXPath. This class is only the dom4j.jar inside my ear.

      I create a simple test Case. The ear contains a war file with a servlet, the dom4j.jar and a services.jar file. The servlet instantiates a class of the services jar. This class loads an xml file and searches nodes using xpath. The application throws an exception.

      I used the V4.0.3SP1 downloaded from sourceforge in a tarball distribution. I used the default configuration.
      The changes that I realized to isolate and override are the following:
      . Change the ear-deployer.xml configuration file. Change the isolation attribute to true.
      <attribute name="Isolated">true</attribute>

      . Create a jboss-app.xml file and deployed in the META-INF directory of my ear file.
      <?xml version='1.0' encoding='UTF-8' ?>
      <!DOCTYPE jboss-app
       PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
       "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd">
      <jboss-app>
       <loader-repository>ar.com.sif.cltest:loader=CLTestApp.ear
       <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
       </loader-repository>
      </jboss-app>


      To track which ClassLoader was involved in the loading of the dom4j jar I created a class attribute, in the class inside de service jar.
      static org.dom4j.DocumentFactory factory = new org.dom4j.DocumentFactory();

      Then, I tracked with jmx-console. With the inclusion of jboss-app.xml, in the console I could see the section:
      ar.com.sif.cltest
      * loader=CLTestApp.ear

      Inside of that, I used displayClassInfo method to view the repository. The output is the following:
      org.dom4j.DocumentFactory Information
      Repository cache version:
      org.dom4j.DocumentFactory(d17ec3).ClassLoader=org.jboss.system.server.NoAnnotationURLClassLoader@199f91c
      ..org.jboss.system.server.NoAnnotationURLClassLoader@199f91c
      ..sun.misc.Launcher$AppClassLoader@53ba3d
      ....file:/C:/java/jboss-4.0.3SP1/bin/run.jar
      ....file:/C:/java/j2sdk1.4.2_06/lib/tools.jar
      ..sun.misc.Launcher$ExtClassLoader@e80a59
      ....file:/C:/java/j2sdk1.4.2_06/jre/lib/ext/dnsns.jar
      ....file:/C:/java/j2sdk1.4.2_06/jre/lib/ext/ldapsec.jar
      ....file:/C:/java/j2sdk1.4.2_06/jre/lib/ext/localedata.jar
      ....file:/C:/java/j2sdk1.4.2_06/jre/lib/ext/sunjce_provider.jar
      ++++CodeSource: (file:/C:/java/jboss-4.0.3SP1/lib/dom4j.jar )
      Implemented Interfaces:
      ++interface java.io.Serializable(1888759)
      ++++ClassLoader: null
      ++++Null CodeSource
      
      ### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@eb1327{ url=file:/C:/java/jboss-4.0.3SP1/server/default/tmp/deploy/tmp59326CLTestApp.ear ,addedOrder=42}
      
      ### Instance1 via UCL: org.jboss.system.server.NoAnnotationURLClassLoader@199f91c
      


      The container is using the library from {jboss.home}/lib instead of the library inside my ear. I think there is a misconfiguration or a pitfall in my configuration.

      Thanks in advance.

      P.D.: How can upload a testCase?