Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

getting java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal when calling the FirefoxDriver contructor using selenium-java 2.30.0 #5245

Closed
lukeis opened this issue Mar 4, 2016 · 13 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 5245

Selenium version: selenium-java 2.30.0
OS: Windows 7 Professional 64bit
Browser: Firefox
Browser version: 15.0
JDK: 1.6.0_34

Hi,

After I have upgraded the selenium-java jar from 2.24.1 to 2.30.0, 
I am getting the following exception at run-time when my code is calling the FirefoxDriver
constructor:

driver = new FirefoxDriver(firefoxBinary, firefoxProfile);


Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.493 sec <<< FAILURE!
testFF(au.com.mycompany.selenium.SeleniumCommonTest)  Time elapsed: 4.43 sec  <<< ERROR!
java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:208)
    at org.openqa.selenium.firefox.internal.FileExtension.readIdFromInstallRdf(FileExtension.java:97)
    at org.openqa.selenium.firefox.internal.FileExtension.writeTo(FileExtension.java:60)
    at org.openqa.selenium.firefox.internal.ClasspathExtension.writeTo(ClasspathExtension.java:63)
    at org.openqa.selenium.firefox.FirefoxProfile.installExtensions(FirefoxProfile.java:465)
    at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:443)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:77)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:188)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:183)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:179)
    at au.com.mycompany.selenium.SeleniumTestParent.setUpFirefoxDriver(SeleniumTestParent.java:70)
    at au.com.mycompany.selenium.SeleniumCommonTest.testFF(SeleniumCommonTest.java:9)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:47)
    at org.junit.rules.RunRules.evaluate(RunRules.java:18)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 65 more


Reported by whatareyoudoingbelly on 2013-02-27 02:18:29

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2013-02-27 18:00:24

  • Labels added: Lang-Java

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

What's your full classpath? Do you use selenium-server-standalone? Or maven? Or any
other way to build the classpath for selenium tests?

Reported by barancev on 2013-02-27 22:47:46

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I found out that it is the apache poi-ooxml 3.9 jar that I'm using for processing xlsx
files which caused the issue.
When building using Maven, it is pulling in the xml-apis jar 1.0.b2 which is not compatible
with the new selenium version. 
My current work around is to exclude the xml-apis jars from the poi dependency.

Dependency:tree
[INFO] +- org.apache.poi:poi-ooxml:jar:3.9:compile
[INFO] |  +- org.apache.poi:poi:jar:3.9:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.5:compile
[INFO] |  +- org.apache.poi:poi-ooxml-schemas:jar:3.9:compile
[INFO] |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
[INFO] |  |     \- stax:stax-api:jar:1.0.1:compile
[INFO] |  \- dom4j:dom4j:jar:1.6.1:compile
[INFO] |     \- xml-apis:xml-apis:jar:1.0.b2:compile

Workaround:
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.9</version>
    <exclusions>
        <exclusion>
            <artifactId>xml-apis</artifactId>
            <groupId>xml-apis</groupId>
        </exclusion>        
    </exclusions>
</dependency>

Reported by whatareyoudoingbelly on 2013-02-27 23:47:15

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Yes, selenium requires xml-apis-1.4.01.jar that is much newer.
Good to know you resolved the issue!

Reported by barancev on 2013-02-28 06:49:58

  • Status changed: Invalid
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Thanks for providing this solution. I was also facing the same issue, now resolved with
including below dependencies to pom.xml:
            <dependency>
                <groupId>xml-apis</groupId>
                <artifactId>xml-apis</artifactId>
                <version>1.4.01</version>
            </dependency>

            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
                <version>3.9</version>
                <exclusions>
                    <exclusion>
                        <artifactId>xml-apis</artifactId>
                        <groupId>xml-apis</groupId>
                    </exclusion>        
                </exclusions>
            </dependency>

Reported by navalkgupta on 2013-03-11 23:49:54

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Seeing the same issue under maven, and looking at the dependency tree, unless I am missing
something, this seems to be a pb with the selenium-java and driver dependencies.
In the tree below notice that a) the firefox driver (which I am trying to instantiate)
doesn't declare a dependency on xml-apis and b) the selenium htmlunit driver declares
one on xml-apis version 1.3.04.

That version is on my classpath, but I still get the NoClassDefFoundError.
Adding an explicit dependency on xml-apis 1.4.01 solved the problem.

+- org.seleniumhq.selenium:selenium-java:jar:2.31.0:test
|  +- org.seleniumhq.selenium:selenium-android-driver:jar:2.31.0:test
|  |  \- org.seleniumhq.selenium:selenium-remote-driver:jar:2.31.0:test
|  |     +- cglib:cglib-nodep:jar:2.1_3:test
|  |     \- org.json:json:jar:20080701:test
|  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.31.0:test
|  +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.31.0:test
|  |  +- org.seleniumhq.selenium:selenium-api:jar:2.31.0:test
|  |  \- net.sourceforge.htmlunit:htmlunit:jar:2.11:test
|  |     +- xalan:xalan:jar:2.7.1:test
|  |     |  \- xalan:serializer:jar:2.7.1:test
|  |     |     \- xml-apis:xml-apis:jar:1.3.04:test
|  |     +- org.apache.commons:commons-lang3:jar:3.1:test
|  |     +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.11:test
|  |     +- net.sourceforge.nekohtml:nekohtml:jar:1.9.17:test
|  |     +- net.sourceforge.cssparser:cssparser:jar:0.9.8:test
|  |     |  \- org.w3c.css:sac:jar:1.3:test
|  |     \- org.eclipse.jetty:jetty-websocket:jar:8.1.7.v20120910:test
|  |        +- org.eclipse.jetty:jetty-util:jar:8.1.7.v20120910:test
|  |        +- org.eclipse.jetty:jetty-io:jar:8.1.7.v20120910:test
|  |        \- org.eclipse.jetty:jetty-http:jar:8.1.7.v20120910:test
|  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.31.0:test
|  |  \- org.apache.commons:commons-exec:jar:1.1:test
|  +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.31.0:test
|  |  +- net.java.dev.jna:jna:jar:3.4.0:test
|  |  \- net.java.dev.jna:platform:jar:3.4.0:test
|  +- org.seleniumhq.selenium:selenium-iphone-driver:jar:2.31.0:test
|  +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.31.0:test
|  +- org.seleniumhq.selenium:selenium-support:jar:2.31.0:test
|  \- org.webbitserver:webbit:jar:0.4.14:test
|     \- io.netty:netty:jar:3.5.2.Final:test

Reported by franck102 on 2013-04-17 15:57:26

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Thank you very much, you are awesome!

Reported by oliinyk.sergii on 2013-08-18 15:07:32

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I encountered the same issue and this resolved it. Thanks so much!

Reported by claytor1 on 2014-05-15 13:09:29

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I am also encountering this issue. Though I have used the above work around and commented
out all the xml-api's in pom.xml still I am getting the above error. :(

Reported by sriram474 on 2014-08-09 18:42:53

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

If you are using selenium and poi in your project then add below dependency to pom.xml

 <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
        </dependency>

Reported by sudheer.test on 2014-08-14 10:04:24

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Even for me exclusion of "xml-apis" from "poi-ooxml" worked .thanks a lot for the posts
.very useful highly appreciated.

-Hari Kiran Mutyala 

Reported by kiron783 on 2015-01-19 21:13:49

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

me too came across the same page, got resolved by your post.
Thanks Lot Guys...!!!

Reported by rgrthiru on 2015-04-09 13:34:07

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 18:16:55

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 4, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant