5 Replies Latest reply on Oct 31, 2018 4:08 PM by jigaronline

    Exclude org.apache.xalan module

    shivanand.mutnale

      We are getting following exception in wildfly-10.1.0.Final

      Caused by: com.coverall.exceptions.ServiceException: 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 jar:file:/E:/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]

      [Loaded org.apache.xml.dtm.ref.DTMManagerDefault from vfs:/E:/Wildfly/wildfly-10.1.0.Final/bin/content/../WEB-INF/lib/xalan-2.7.1.jar]

      [Loaded org.apache.xml.dtm.DTMManager from jar:file:/E:/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]

       

      These classes are currently loading form xalan-2.7.1.jbossorg-2.jar and we want these classes to be loaded from xalan-2.7.1.jar provided inside war file.

       

      Tried to exclude org.apache.xalan module by excluding the following widlfly modules in jboss-deployment-structure.xml file.But it is not working.

       

      <?xml version="1.0"?>
      <jboss-deployment-structure>
      <deployment>
      <exclusions>
      <module name="javax.servlet.jstl.api" />
      <module name="org.apache.santuario.xmlsec" />
      <module name="org.apache.ws.security" />
      <module name="org.jboss.as.appclient" />
      <module name="org.jboss.as.cli" />
      <module name="org.jboss.as.host-controller" />
      <module name="org.jboss.as.jdr" />
      <module name="org.jboss.as.server" />
      <module name="org.jboss.as.standalone" />
      <module name="org.jboss.as.webservices.server.integration" />
      <module name="org.apache.xerces" />
      <module name="org.apache.xalan" />
      </exclusions>
      <dependencies>
      <system>
      <paths>
      <path name="com/sun/org/apache/xerces/internal/jaxp/datatype"/>
      <path name="com/sun/jndi/rmi" />
      <path name="com/sun/jndi/rmi/registry"/>
      </paths>
      </system>
      </dependencies>
      </deployment>
      </jboss-deployment-structure>
      

       

      Please suggest us some solution by which classes would load only from xalan.2.7.1.jar  from WAR.

        • 1. Re: Exclude org.apache.xalan module
          dmlloyd

          Your application should be loading your own xalan classes even without the jboss-deployment-structure.xml descriptor, so I think this is a bug.  It may be fixed as of the upcoming WildFly 13 though; in that release, the way JAXP classes are resolved has been improved.

          • 2. Re: Exclude org.apache.xalan module
            jaikiran

            As David says, you won't need a jboss-deployment-structure.xml to make this work and this should work fine out of the box. In fact I just added a test case locally to try this against WildFly 10.1.0, 12 and even latest upstream master. It works fine on all these versions. Can you post us the relevant code where you are dealing with the transform APIs and the complete exception stacktrace you see (it would be preferable if you can try this against WildFly 12).

             

            The test case I added is now in my repo here [1]. dmlloyd, we already have a XercesUsageTestCase in our basic testsuite which was added very early in AS7 days to verify usages of "tricky" libraries like this one. Do you think this new xalan usage test case is worth being added to the testsuite? If so, I can issue a PR which will contain that test case.

             

            [1] https://github.com/jaikiran/wildfly/commit/d967c95f9bc0356f210fbc68dc2196eadbdab13a

            • 3. Re: Exclude org.apache.xalan module
              dmlloyd

              Sure, I think this is a worthwhile addition, just to ensure we don't regress in this area.

              • 4. Re: Exclude org.apache.xalan module
                shivanand.mutnale

                Thanks for the reply David and Jaikiran.

                 

                Following is the code that we are using to evaluate xpath expression.

                 

                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                    DocumentBuilder builder = factory.newDocumentBuilder();
                    Document doc = builder.parse(this.getClass().getClassLoader().getResourceAsStream("/test.xml"));
                    XPathFactory xPathFactory = XPathFactory.newInstance();
                    XPath xpath = xPathFactory.newXPath();
                    XPathExpression xPathExpression = xpath.compile("ISO//PassportSvcRs");
                    Element PassportSvcRsEl = (Element) xPathExpression.evaluate(doc,XPathConstants.NODE);
                    XPathExpression statusCdXpath = xpath.compile(".//Reports//Report//Status//StatusCd");
                

                 

                This code works fine when we have only xalan dependency in war file.

                The class loading log for this is as below:

                [Loaded io.undertow.servlet.api.LifecycleInterceptor$LifecycleContext from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded io.undertow.servlet.core.LifecyleInterceptorInvocation from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded io.undertow.servlet.spec.ServletConfigImpl from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded org.apache.xpath.jaxp.XPathFactoryImpl from vfs:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/bin/content/XPathTest.war/WEB-INF/lib/xalan-2.7.1.jar]
                [Loaded org.apache.xpath.jaxp.XPathImpl from vfs:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/bin/content/XPathTest.war/WEB-INF/lib/xalan-2.7.1.jar]
                [Loaded org.apache.xml.utils.PrefixResolver from vfs:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/bin/content/XPathTest.war/WEB-INF/lib/xalan-2.7.1.jar]
                [Loaded org.apache.xpath.VariableStack from vfs:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/bin/content/XPathTest.war/WEB-INF/lib/xalan-2.7.1.jar]
                [Loaded org.apache.xpath.jaxp.JAXPVariableStack from vfs:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/bin/content/XPathTest.war/WEB-INF/lib/xalan-2.7.1.jar]
                

                 

                When we add other dependency such as cxf ,spring,hibernate etc... the code doesn't work.

                The class loading log for this is as below

                [Loaded io.undertow.servlet.api.LifecycleInterceptor$LifecycleContext from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded io.undertow.servlet.core.LifecyleInterceptorInvocation from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded io.undertow.servlet.spec.ServletConfigImpl from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/io/undertow/servlet/main/undertow-servlet-1.4.0.Final.jar!/]
                [Loaded org.apache.xpath.jaxp.XPathImpl from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded org.apache.xml.utils.PrefixResolver from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded javax.xml.xpath.XPathFunctionException from C:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar]
                [Loaded org.apache.xpath.VariableStack from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded org.apache.xpath.jaxp.JAXPVariableStack from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded org.apache.xpath.ExpressionOwner from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded org.apache.xpath.XPath from jar:file:/D:/Softwares/Wildfly/wildfly-10.1.0.Final/modules/system/layers/base/org/apache/xalan/main/xalan-2.7.1.jbossorg-2.jar!/]
                [Loaded javax.xml.transform.SourceLocator from C:\Program Files\Java\jdk1.8.0_25\jre\lib\rt.jar]
                

                 

                Also I have tried this in wildfly-12.0.0.Final.

                • 5. Re: Exclude org.apache.xalan module
                  jigaronline

                  "It may be fixed as of the upcoming WildFly 13 though; in that release, the way JAXP classes are resolved has been improved"

                   

                  We were able to reproduce the same in Wildfly 13. Can you provide the reference to this issue, if already created one to help track? Or should we create another issue with details in Wildfly 13?