2

I want to use saxon to process xpath in a jira module. Unit tests covering the problematic code were running fine in eclipse, so I have deployed the module, and ...

I have encountered the dreaded

java.lang.ClassCastException: org.apache.xerces.jaxp.SAXParserFactoryImpl cannot be cast to javax.xml.parsers.SAXParserFactory (see Dealing with "Xerces hell" in Java/Maven?)

I tried to exclude xml-apis from saxon dependencies, as it is suggested in https://answers.atlassian.com/questions/104121/i-m-blocked-help-cannot-be-cast-to-javax-xml-parsers-saxparserfactory

Now I got w3c.dom missing, which is strange, because I would bet my hat that it is existing somewhere in jira. I added dom4j to pom dependencies nevertheless, and got

java.lang.NoClassDefFoundError: Could not initialize class net.sf.saxon.Configuration

With no indication of which class is missing.

Here is the code with the initial problem: https://github.com/magwas/andreymarkelov-atlas-plugins-requestedfields/tree/feature/xsltfixes

the patch leading to current state is at http://pastebin.com/vwR43hHt

What would be the solution?

Community
  • 1
  • 1
Árpád Magosányi
  • 1,394
  • 2
  • 19
  • 35

1 Answers1

0

Okay, figured it out. I am not sure why, so an analysis would be welcome.

     <dependency>
       <groupId>net.sf.saxon</groupId>
       <artifactId>Saxon-HE</artifactId>
       <version>9.4</version>
       <exclusions>
        <exclusion>
            <artifactId>xom</artifactId>
            <groupId>xom</groupId>
        </exclusion>
        <exclusion>
            <artifactId>dom4j</artifactId>
            <groupId>dom4j</groupId>
        </exclusion>
       </exclusions>
     </dependency>
Árpád Magosányi
  • 1,394
  • 2
  • 19
  • 35
  • Temporarily remove your exclusions, add a temporary dependency for groupId=`com.atlassian.jira`, artifactId=`jira-core`, version=`yourJiraVersion`, scope=`provided`, and then run `atlas-mvn dependency:tree`. This will show you all of the transitive dependencies for your project, so you will be able to see which other xerces-type modules are being used. You can also see all dependencies of your manually-included saxon module and see what they duplicate in JIRA. – Scott Dudley May 26 '14 at 14:11