0 Replies Latest reply on Aug 31, 2011 10:59 AM by marko_v

    JBoss 4.2.3 - ClassLoading issue

    marko_v Newbie



      I am currently working on an isolation of an EAR. This EAR has the following structure:


      EAR/META-INF/lib/xalan-2.7.1.jar (library reference defined in MANIFEST.MF)


      EAR/foobar-app.war (WEB-INF/lib is empty because of the decision, to centralize the dependencies of the WARs in the EAR to META-INF/lib if possible. So only those dependencies, which differ in versions and may cause conflicts stay in WEB-INF/lib.




      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss-app PUBLIC
          "-//JBoss//DTD J2EE Application 1.4//EN"


      I am getting this Exception:


      rg.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.util.ArrayList' to required type 'java.lang.Iterable' for property 'descriptorFilenames'; nested exception is java.lang.ClassCastException: org.apache.xml.dtm.ref.DTMManagerDefault cannot be cast to org.apache.xml.dtm.DTMManager


      According to the classloading output using -verbose:class on startup of JBoss the following classes are loaded that way:


      [Loaded org.apache.xml.dtm.ref.DTMManagerDefault from C:\...\jboss\lib\endorsed\xalan.jar]

      [Loaded org.apache.xml.dtm.DTMManager from file:/.../foo-bar.ear-contents/META-INF/lib/xalan-2.7.1.jar]


      The outcome of debugging this issue is, that even the configuration file for the implementation has been loaded from:





      So... why does the WebAppClassLoader of the foobar-app.war not load the implementation from its parent classloader (the classloader of the EAR)? Why does the EAR HirarchicalClassLoader delegates to its parent classloader in this case instead of checking the EAR/META-INF/lib first?


      If I put the xalan-2.7.1.jar in the WAR itself, it works but then we have to put it in all WARs included in the EAR, which is against the idea to clean up the depenencies and save some space. This actually works only, because all classes are loaded from the xalan.jar provided by JBoss and the ones provided by the web applications themselves are ignored.



      Thank you very much for any help.




      Btw. the output of the corresponding MBean operation on the jmx-console displayClassInfo() with the parameter 'org.apache.xml.dtm.ref.DTMManagerDefault' results in:



      org.apache.xml.dtm.ref.DTMManagerDefault Information Not loaded in repository cache

      ### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3@79895f{ url=file:/C:/.../foo-bar.ear ,addedOrder=47}
      ### Instance1 via UCL: org.jboss.system.server.NoAnnotationURLClassLoader@704baa


      I guess instance 1 is being used instead of instance 0.


      Without including the jboss-app.xml in EAR/META-INF/ the class org.apache.xml.dtm.ref.DTMManagerDefault is loaded from the META-INF/lib/xalan-2.7.1.jar.



      Kind regards,