Maven运行Selenium报错org/w3c/dom/ElementTraversal

项目使用maven 构建,并且使用集成测试(integration-test)。

在命令行中运行mvn clean deploy tomcat:undeploy时,报错:

java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

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)  

 

解决方法:

在pom中添加依赖

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

  详情请参阅

http://stackoverflow.com/questions/10234201/appengine-error-java-lang-noclassdeffounderror-org-w3c-dom-elementtraversal

posted @ 2016-02-29 11:21  —八戒—  阅读(4929)  评论(0编辑  收藏  举报