当前位置:   article > 正文

Selenium-Java 报错Exception in thread “main“ java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraver_exception in thread "main" java.lang.noclassdeffou

exception in thread "main" java.lang.noclassdeffounderror: org/w3c/dom/eleme

Maven项目 引入依赖即可。

  1. <!-- https://mvnrepository.com/artifact/xml-apis/xml-apis -->
  2. <dependency>
  3. <groupId>xml-apis</groupId>
  4. <artifactId>xml-apis</artifactId>
  5. <version>1.4.01</version>
  6. </dependency>

Gradle在引入"xml-apis:xml-apis:1.4.01"依赖时,始终无法正常引入,需引入解决策略

  1. configurations.all {
  2. resolutionStrategy {
  3. force 'xml-apis:xml-apis:1.4.01'
  4. }
  5. }

我本人使用gradle构建项目,引入如下

  1. configurations {
  2. compile.exclude group: "ch.qos.logback"
  3. compile.exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
  4. compile.exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
  5. compile.exclude group: "org.apache.tomcat", module: "tomcat-jdbc"
  6. compile.exclude group: "com.zaxxer", module: "HikariCP-java7"
  7. all {
  8. resolutionStrategy {
  9. force 'xml-apis:xml-apis:1.4.01'
  10. }
  11. }
  12. }

贴出报错图

 

  1. Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
  2. at java.lang.ClassLoader.defineClass1(Native Method)
  3. at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  4. at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  5. at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  6. at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  7. at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  8. at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  9. at java.security.AccessController.doPrivileged(Native Method)
  10. at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  11. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  12. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
  13. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  14. at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown Source)
  15. at org.apache.xerces.xinclude.XIncludeHandler.startDocument(Unknown Source)
  16. at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown Source)
  17. at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown Source)
  18. at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown Source)
  19. at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  20. at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
  21. at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
  22. at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
  23. at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
  24. at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:95)
  25. at org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
  26. at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:454)
  27. at org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:386)
  28. at org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:261)
  29. at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:616)
  30. at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:637)
  31. at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
  32. at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
  33. at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
  34. at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
  35. at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:121)
  36. at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
  37. at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
  38. at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
  39. at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
  40. at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
  41. at us.codecraft.webmagic.scheduler.DuplicateRemovedScheduler.<init>(DuplicateRemovedScheduler.java:19)
  42. at us.codecraft.webmagic.scheduler.QueueScheduler.<init>(QueueScheduler.java:19)
  43. at us.codecraft.webmagic.Spider.<init>(Spider.java:75)
  44. at us.codecraft.webmagic.Spider.create(Spider.java:119)
  45. at com.amazon.common.utils.spider.AmanzonPageProcessor.main(AmanzonPageProcessor.java:43)
  46. Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
  47. at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
  48. at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  49. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
  50. at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  51. ... 44 more

如果对你有帮助 ,欢迎点赞评论哦

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/279229
推荐阅读
相关标签
  

闽ICP备14008679号