0

I'm trying to use HtmlUnit in a Kotlin project but I get the following error when I compile:

Error:Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class com.gargoylesoftware.htmlunit.html.DomElement, unresolved supertypes: ElementTraversal

This is because ElementTraversal is a java 7 feature. How can I solve this?

Marcin Koziński
  • 10,835
  • 3
  • 47
  • 61
Johnny
  • 7,073
  • 9
  • 46
  • 72
  • You don't indicate how you compile, and what JDK you are using to compile. And are you compiling in an IDE (which?), or build system (which?)? – Jayson Minard Jun 03 '16 at 16:51

1 Answers1

0

The org.w3c.dom.ElementTraversal is part of xml-apis which is a dependency of xerces:xercesImpl. The xerces:xercesImpl is in turn a dependency of htmlunit.

Make sure to add the transitive dependencies of htmlunit to your project.

With gradle all that is needed is:

compile 'net.sourceforge.htmlunit:htmlunit:2.22'
miensol
  • 39,733
  • 7
  • 116
  • 112
  • Yeah, I have that in my maven as ` net.sourceforge.htmlunit htmlunit 2.22 ` – Johnny Jun 02 '16 at 08:21
  • @Johnny take a look at your [`dependency:tree`](http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html) – miensol Jun 02 '16 at 08:40
  • Fixed by adding ` xml-apis xml-apis 1.4.01 `, which is strange as it's a dependency of HtmlUnit. – Johnny Jun 02 '16 at 08:46