NoClassDefFoundError: org/w3c/dom/ElementTraversal

87,539

Solution 1

It looks like ElementTraversal is part of xml-apis-2.10.0.jar which should have been provided with your Shibboleth installation.

So if you were following these instructions you should also have followed this step:

Endorse Xerces and Xalan by creating the directory JETTY_HOME/lib/endorsed/ and copy the .jar files included in the IdP source endorsed/ directory into the newly created directory.

So long as you copied all the jar files appropriately, it should be okay. My guess is that you missed out that step - or perhaps only copied the jar files with Xalan or Xerces in the name, and missed the other two.

Solution 2

In my case the problem was fixed by changing xml-apis version from 1.3.04 to 1.4.01.

BTW, version 2.10.0 doesn't exist in Maven Central (I'm curious where did Jon Skeet find it).

Solution 3

Add this in your file, to resolve the dependency:

 <dependency>
      <groupId>xml-apis</groupId>
      <artifactId>xml-apis</artifactId>
      <version>1.4.01</version>
 </dependency>
Share:
87,539
Mustapha Aoussar
Author by

Mustapha Aoussar

Updated on July 15, 2022

Comments

  • Mustapha Aoussar
    Mustapha Aoussar almost 2 years

    I installed Jetty 7 and configured it correcty for IdP Shibboleth following this guide: https://wiki.shibboleth.net/confluence/display/SHIB2/IdPJetty7Prepare

    But when i try to start Jetty I get this error:

    NoClassDefFoundError: org/w3c/dom/ElementTraversal
    

    To resolve this issue i need to install the ElementTraversal dependency and include it on my classpath.
    But how can i accomplish this? Do i need to download this Class [ElementTraversal.class] or a .jar file? and where i can place it? in the JETTY_HOME? Do I need to export the CLASSPATH?

    Can someone help me?
    Thank you so much!

  • Mustapha Aoussar
    Mustapha Aoussar almost 11 years
    Thank you so much, but I also have followed that step. I copied the xalan-2.7.1.jar and xercesImpl-2.10.0.jar correctly to JETTY_HOME/lib/endorsed/ and I added the following line in start.ini: -Djava.endorsed.dirs=lib/endorsed I followed all the steps.
  • Mustapha Aoussar
    Mustapha Aoussar almost 11 years
    I have the xml-apis-2.10.0.jar in opt/shibboleth-idp/lib/endorsed/xml-apis-2.10.0.jar.. I think that the problem could be in the path defined in start.ini. I can try to use an absolute path -Djava.endorsed.dirs=/home/user/webapps/jetty/lib/endorsed
  • Mustapha Aoussar
    Mustapha Aoussar almost 11 years
    Doesn't work also with the absolute path. Thank you Jon Skeet, it has given me great pleasure and honour to have received a response from you to my question.
  • Jon Skeet
    Jon Skeet almost 11 years
    @Fuiba: It's not clear whether you copied all four jar files into JETTY_HOME/lib/endorsed. You say you've got xml-apis-2.10.0.jar in opt/shibboleth-idp/lib/endorsed, but should have copied it along with the xalan and xerces jar files. Did you?
  • Mustapha Aoussar
    Mustapha Aoussar almost 11 years
    I copied only xalan-2.7.1.jar and xercesImpl-2.10.0.jar to JETTY_HOME/lib/endorsed.
  • Mustapha Aoussar
    Mustapha Aoussar almost 11 years
    There was mistakes in this guide wiki.shibboleth.net/confluence/display/SHIB2/IdPJetty7Prepar‌​e I had to copy all the 5 jar files included in the IdP source endorsed/ to JETTY_HOME/lib/endorsed/, not only Xerces and Xalan. I contacted them and they edited the wiki.
  • Jon Skeet
    Jon Skeet almost 11 years
    @Fuiba: But before the change it already said "copy the .jar files included in the IdP source endorsed/ directory" - I don't think it was a mistake as such, although I agree it's clearer now.
  • Sled
    Sled almost 10 years
    I think this is the Maven dependency needed: search.maven.org/…
  • Tiina
    Tiina over 7 years
    A supplement of this useful answer from 2016 Dec, in maven there is also a 2.0.0 and 2.0.2 version of xml-apis, but they are not new jar, they are just a pom, saying relocation to 1.0.b2. I don't know which team is behind this, but if they don't want to open their code they don't have to put it in maven, this is understandable. But they put it there, and relocation it to a lower version, which is a waste of many developers time (I see over 100 usages of 2.0 version), and this is not acceptable.
  • Ahmed Hasn.
    Ahmed Hasn. over 7 years
    @Tiina this is excatly my case...a shame that I couldn't find this comment first. However, can you complete this and tell us how to get the correct versions using maven?
  • Tiina
    Tiina over 7 years
    @ConquerorsHaki I usually find the correct version using stackoverflow. And try to use the version that has both higher version and acceptable number of usages. While I use xml-apis 2.0 but don't have the problem solved, I looked into its pom, and I found that "relocation to a lower" oops. Usually people would think about their Internet issue first when they don't see a difference after they update their pom. That was my first concern too.
  • supertramp
    supertramp over 5 years
    This magicaly worked for me and the code: ` private static void generateHTMLFromPDF(String filename) throws IOException, ParserConfigurationException { PDDocument pdf = PDDocument.load(new File(filename)); Writer output = new PrintWriter("pdf.html", "utf-8"); new PDFDomTree().writeText(pdf, output); output.close(); }` started to work!