5 Replies Latest reply: Jun 17, 2009 2:10 AM by Tar Antul RSS

    Classloader issues in JBoss 5.0.0

    vvfvff fvfdvdf Newbie

      Hi
      Am using JBoss AS 5.0.0 on jdk5.
      Deployment of my war file fails. I see this error:
      ------------------------------------------------------------
      08:31:46,225 ERROR [StandardContext] Context [/myapp] startup failed due to previous errors
      java.lang.LinkageError: loader constraints violated when linking org/xml/sax/Parser class
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
      at org.apache.tomcat.util.digester.Digester.getParser(Digester.java:704)
      at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:978)
      -------------------------------------------------------------

      Seems like three might be conflict between jboss's "lib/endorsed/xercesImpl.jar" and my app's "WEB-INF/lib/xercesImpl.jar".


      I tried the following below.
      Created file "myapp.war/WEB-INF/jboss-web.xml"
      -----------------------------------
      <jboss-web>
      <class-loading java2ClassLoadingCompliance='false'>
      <loader-repository>
      com.example:loader='myapp.war'
      <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
      </loader-repository>
      </class-loading>
      </jboss-web>
      -----------------------------------

      I removed the temporary files and restarted the webcontainer.
      But this didn't resolve the problem.

      How do I configure the classloading, to use my app's xercesImpl.jar over the one in JBoss ?

        • 1. Re: Classloader issues in JBoss 5.0.0
          Tar Antul Newbie

          Have the same problem. Does someone know the solution?

          • 3. Re: Classloader issues in JBoss 5.0.0
            Tar Antul Newbie

            Thank you for this tip. Unfortunately the error is not resolved.

            I removed the following lines out of the jboss-web.xml:

            <class-loading>
             <loader-repository>reportal.loader:loader=reportal.war
             <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
             </loader-repository>
            </class-loading>


            Then I have created the jboss-clasloading.xml with following content:
            <?xml version="1.0" encoding="UTF-8"?>
            
            <classloading xmlns="urn:jboss:classloading:1.0"
             name="reportal.war"
             domain="MyWar_Domain"
             export-all="NON_EMPTY"
             import-all="false">
            </classloading>


            Then I get the same error regarding a SAX parser:

            ...
            2009-06-15 16:29:56,863 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/reportal
            2009-06-15 16:29:56,863 ERROR [org.jboss.web.tomcat.service.deployers.JBossContextConfig] (HDScanner) XML error parsing: context.xml
            org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
             at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)
             at org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)
             at org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:536)
             at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
            
            ...
            
            Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new SAX parser
             at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.<init>(SaxJBossXBParser.java:97)
             at org.jboss.xb.binding.UnmarshallerImpl.<init>(UnmarshallerImpl.java:56)
             at org.jboss.xb.binding.UnmarshallerFactory$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)
             ... 68 more
            Caused by: javax.xml.parsers.ParserConfigurationException: Feature 'http://apache.org/xml/features/xinclude' is not recognized.
             at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
             at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.<init>(SaxJBossXBParser.java:92)
             ... 70 more
            ...
            


            After remowing the xercesImpl the application can be deployed, but then I get a runtime exception while using CollectionUtils.isNotEmpty(...).
            It seems like the commons-collections.jar from JBoss is being used and that it is a version prior to 3.2, where this isNotEmpty-method had been introduced. The appropriate commons-collections-3.2.jar is in the WEB-INF/lib directory of my application. Anyway the application was previously running in Tomcat without any problems.

            2009-06-15 16:52:22,136 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/reportal].[action]] (http-127.0.0.1-8080-4) Servlet.service() for servlet action threw exception
            java.lang.NoSuchMethodError: org.apache.commons.collections.CollectionUtils.isNotEmpty(Ljava/util/Collection;)Z


            Thats why I think, that the JBoss libs are still loaded before the application libs.


            Am I doing something wrong or is there some other possibility?

            • 4. Re: Classloader issues in JBoss 5.0.0
              Tar Antul Newbie

              By the way. Without a jboss-clasloading.xml the application cann not be deployed at all. Obviousely it's because of the Log4j, I'd like to use from my WEB-INF/lib directory:

              Caused by: org.apache.commons.logging.LogConfigurationException: User-specified log class 'org.apache.commons.logging.impl.Log4JLogger' cannot be found or is not useable.
               at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:798)


              That's all is very confusing.

              • 5. Re: Classloader issues in JBoss 5.0.0
                Tar Antul Newbie

                I have forgotten to mention, that I'm using JBoss 5.1.0.GA