What steps will reproduce the problem?
1. Start with an empty Maven project
2. Add selenium-java dependency
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.2</version>
</dependency>
3. Test it with simple main class:
public static void main(String[] args) {
new FirefoxDriver();
}
}
4. It should run without errors and launch Firefox browser (providing you have
one installed)
5. Then add reflections dependency after selenium:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC2</version>
</dependency>
6. Now start again main class and there will be an error
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
7. The same will happen if you swap both dependencies in the pom.xml
8. The reason I found is too old xml-apis dependency in the reflections
artifact. The solution fixing it temporary was to insert a newer version of
xml-apis explicitly in the pom.xml to override the older one in the classpath.
So only in the following configuration both selenium and reflections work
together:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9-RC2</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.2</version>
</dependency>
I think you should update the xml-apis dependency in org.reflections from
current 1.0.b2 to 1.4.01, which is widely used by other artifacts.
What version of the product are you using? On what operating system?
org.reflections:reflections:0.9.9-RC2 on Windows 7 x64.
Original issue reported on code.google.com by klosi...@gmail.com on 14 Sep 2014 at 8:48
Original issue reported on code.google.com by
klosi...@gmail.com
on 14 Sep 2014 at 8:48