34

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
  • 5,833
  • 15
  • 62
  • 107

4 Answers4

31

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.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • 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 Jul 07 '13 at 19:40
  • 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 Jul 07 '13 at 19:57
  • 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. – Mustapha Aoussar Jul 07 '13 at 20:26
  • @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? – Jon Skeet Jul 07 '13 at 20:34
  • I copied only `xalan-2.7.1.jar` and `xercesImpl-2.10.0.jar` to JETTY_HOME/lib/endorsed. – Mustapha Aoussar Jul 07 '13 at 21:10
  • There was mistakes in this guide https://wiki.shibboleth.net/confluence/display/SHIB2/IdPJetty7Prepare 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. – Mustapha Aoussar Jul 09 '13 at 13:12
  • 1
    @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. – Jon Skeet Jul 09 '13 at 13:16
  • I think this is the Maven dependency needed: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22xml-apis%22%20AND%20a%3A%22xml-apis%22 – Sled Jul 15 '14 at 18:54
23

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).

yegor256
  • 102,010
  • 123
  • 446
  • 597
  • 5
    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. – Tiina Dec 20 '16 at 03:42
  • 1
    @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? – Ahmed Hasn. Jan 06 '17 at 10:50
  • @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. – Tiina Jan 09 '17 at 00:54
  • Hello from 2023, `org.w3c.dom.ElementTraversal` implementation is there in 1.4.01 but it's implementation of `javax.xml.parsers.DocumentBuilderFactory` conflict with the one in jre and I started having another issue in a legacy ant project. – Davut Gürbüz Feb 21 '23 at 14:35
22

Add this in your file, to resolve the dependency:

 <dependency>
      <groupId>xml-apis</groupId>
      <artifactId>xml-apis</artifactId>
      <version>1.4.01</version>
 </dependency>
Bsquare ℬℬ
  • 4,423
  • 11
  • 24
  • 44
Ran Adler
  • 3,587
  • 30
  • 27
  • 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! – supertramp Mar 18 '19 at 18:18
0

In my case, it was gradle-spoon-plugin. None of the solutions did help. What we could do was just remove it totally from the project.

See: https://github.com/jaredsburrows/gradle-spoon-plugin/issues/96

nopopon
  • 257
  • 3
  • 6