2 Replies Latest reply on Jul 1, 2015 12:26 PM by aemon

    JBOSS EAP 6.1 - How to exclude Xerces and Replace it by RT.jar (JRE) for xml parsing

    aemon

      Hello,

       

      I have a problem with my Web App on JBOSS EAP 6.1.0.

      When I parse an XML file I don't have an error but the result is different from the same Web App running on tomcat / WebSphere / Weblogic (My Web App must be compatible with all those AS).

       

      For a better understanding, a comparison of log between Tomcat and JBOSS

       

      jboss_compare_sax_log.png

      Source Code corresponding to the log : (don't be scared by the this.writelog() it's just for debug with local printing)

      jboss_java_print_log.png

       

       

      In my understanding the problem occurs with SAX Parser which doesn't have the same behaviour between AS (Tomcat is not a full AS but it's easier to say that)

      Sax Parser use rt.jar when running on tomcat instead of using xercesImpl 2.9.1 when running on JBOSS EAP 6.1.0.

       

      I have decided to exclude xerces from the classloading and add the dependency with rt.jar in jboss-deployment-structure.xml

      But I encounter a new problem : How I could set the dependency with rt.jar as it is not in a jar library but in JRE ?

       

      my jboss-deployment-structure.xml :

      jboss-deployment-structure.png

       

      Note : We exclude web services subsystem to avoid conflict with CXF.

      It generate warning on deployment (I don't think there is a link with my XML Parsing problem but this is the startup log)


      15:49:38,225 WARN  [org.jboss.as.ee] (MSC service thread 1-9) JBAS011006: Not installing optional component org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation

        at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:607) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:80) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

       

       

      15:49:38,225 WARN  [org.jboss.as.ee] (MSC service thread 1-9) JBAS011006: Not installing optional component org.eclipse.jetty.continuation.Servlet3Continuation$1 due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.eclipse.jetty.continuation.Servlet3Continuation$1

        at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:607) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:80) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

       

       

      15:49:38,225 WARN  [org.jboss.as.ee] (MSC service thread 1-9) JBAS011006: Not installing optional component org.eclipse.jetty.continuation.Servlet3Continuation$2 due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011054: Could not find default constructor for class org.eclipse.jetty.continuation.Servlet3Continuation$2

        at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.java:607) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:80) [jboss-as-ee-7.2.0.Final-redhat-8.jar:7.2.0.Final-redhat-8]

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_60]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_60]

        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_60]

       

       

      15:49:38,365 INFO  [org.infinispan.factories.GlobalComponentRegistry] (ServerService Thread Pool -- 49) ISPN000128: Infinispan version: Infinispan 'Delirium' 5.2.6.Final

       

      Is my analysis seems correct ?

      If yes, how could I exclude xerces from classloading and replace it by rt.jar ?

      If not, what will be the best solution to solve it ? (using xerces 2.9.1 in my web app instead of sax from JRE ?)

       

      Let me know if you need further information (log ?) ?

        • 1. Re: JBOSS EAP 6.1 - How to exclude Xerces and Replace it by RT.jar (JRE) for xml parsing
          mmusaji

          Excluding xerces is not the right approach from what I understand. This will break a lot of things in JBoss because we use this internally.

           

          What you want to do is basically tell JBoss to use a packaged version of a JAXP implementation, or use the one in JDK. The way the javax.xml.parsers implementation is chosen is what you need to change. This can be done by code when you create your DocumentBuilderFactory/SAXParserFactory or by defining a META-INF/services file.

           

          If you take a look under $JBOSS_HOME/modules/system/layers/base/org/apache/xerces/xerces-Impl.jar/META-INF/services/javax.xml.parsers.* you'll see the implementation being used in JBoss - in this case Xerces.

           

          In your application, try adding a META-INF/services/javax.xml.parsers.DocumentBuilderFactory in your deployment that contains the package you want to use instead. Now when you call newInstance() it should pick up the one defined here. I say it *should*, I've not actually tried this for a while but this is what I remember.

           

          The other option is to add a jaxp.properties files in your JRE to see if the javax.xml.parsers.DocumentBuilderFactory property is set. See Using the Properties (The Java™ Tutorials >                    Java API for XML Processing (JAXP) > JAXP 1.5 and New Pro…

           

          I hope that is what you intended and it helps.

           

          Mus

          • 2. Re: JBOSS EAP 6.1 - How to exclude Xerces and Replace it by RT.jar (JRE) for xml parsing
            aemon

            Yes, I’m agree, Excluding Xerces is not the right approach but due to my leak of knowledge on JBoss I think it was the only solution for my problem.

             

            I will try to add a META-INF/services to specify the implementation of javax.xml.parsers.DocumentBuilderFactory (Currently I am not able to find which implementation use the JRE with RT.jar)

             

            Thank you for your answer ! It provide new helpful perspective.

             

            EDIT : RT.jar use the following implementation : com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

            I had a META-INF/services/javax.xml.parsers.DocumentBuilderFactory but it doesn't change the Sax Parser.


            I follow this link to print information on implentation : http://stackoverflow.com/questions/1798366/how-do-i-find-out-which-jaxp-implementation-is-in-use-and-where-it-was-loaded-fr


            But the Implementation is still from JBOSS :

            DocumentBuilderFactory implementation: __redirected.__DocumentBuilderFactory loaded from: file:/C:/Jboss-eap-6.1.0/jboss-modules.jar

            XPathFactory implementation: __redirected.__XPathFactory loaded from: file:/C:/Jboss-eap-6.1.0/jboss-modules.jar

            TransformerFactory implementation: __redirected.__TransformerFactory loaded from: file:/C:/Jboss-eap-6.1.0/jboss-modules.jar

            SAXParserFactory implementation: __redirected.__SAXParserFactory loaded from: file:/C:/Jboss-eap-6.1.0/jboss-modules.jar

             

            Next Step is to use System property to set implementation.