External transitive xalan dependency in SpringBoot application leads to exception - Can not transform a Source of type javax.xml.transform.stax.StAXSource

Solution In Progress - Updated -

Environment

  • Red Hat Fuse
    • 7.0

Issue

  • We are in the process of preparing a POC with Red Hat for Openshift. For that purpose we have picked one of our application that we want to run in OpenShift. At same time we are tying out if we can change our setup and move our BluePrint/Karaf to SpingBoot/SpringXML.
BUILD:
mvn clean install 

RUN:
java -jar ./target/pnd-0.0.1-SNAPSHOT.jar
java -jar ./target/pnd-0.0.2-SNAPSHOT.jar
java -jar ./target/pnd-0.0.3-SNAPSHOT.jar
  • Then send SOAP request pnd.xml to http://localhost:8080/services/ws/pnd using soap-ui.
  • Here is what we see. PND1 works fine. PND2 and PND3 will fail.
  • Only difference in PND2 inclusion of dependency net.sourceforge.htmlunit in pom. xml. (No code actually uses this library)
  • Can you explain why this is happening?

Resolution

  • JIRA ENTESB-9167 is logged.
  • We have to exclude xalan dependency from htmlunit dependency to avoid xalan dependency following way.
          <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.20</version>
             <exclusions>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
            </exclusions> 
         </dependency>
  • The xalan in the dependency is the culprit. The current camel XmlConverter can't work very well with external xalan impl if the input of the source somehow is null, but the JDK xalan impl is more lenient in this case, we should avoid using external xalan dependency.
  • We can run below maven command in our project where pom.xml exists, this will list all compile time dependencies. Thus it will help us to identify the direct and transitive dependencies.
mvn dependency:tree

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments