How to fix NoClassDefFoundError: CircularOutputStream error?

試著忘記壹切 提交于 2019-12-12 09:43:09

问题


I was just creating a simple maven project for Selenium WebDriver(a.k.a. Selenium 2) automated test for headless testing. I added the PhantomJS driver dependency as follows with other dependencies in pom.xml:

<dependency>
    <groupId>com.github.detro</groupId>
    <artifactId>phantomjsdriver</artifactId>
    <version>1.2.0</version>
</dependency>

But it is getting error:

java.lang.NoClassDefFoundError: org/openqa/selenium/io/CircularOutputStream
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at jp.co.skygate.home.HomePageLogin.setUp(HomePageLogin.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at

Just removing the PhantomJS dependency from the pom.xml solves the problem and it executes fine. Can someone help me find the problem?

Thanks in advance.


回答1:


At last I got the solution.

Adding PhantomJS v.1.2.0 replaces the selenium-remote-driver-2.53.0.jar with selenium-remote-driver-2.41.0.jar and hence breaks down everything. And now using V.2.41.0,

driver = new FirefoxDriver();

instead of

driver = new PhantomJSDriver(caps);

generates the error.




回答2:


As per @Ripon comment, the problem is in version compatibility, so Selenium Server 2.53.x should be used along with Phantom JS 1.3.x .

Here is lines in the pom.xml which should work:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.53.1</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.codeborne</groupId>
  <artifactId>phantomjsdriver</artifactId>
  <version>1.3.0</version>
</dependency>

Then run mvn dependency:tree to build and display the dependency tree for this project.

If you're not using Maven, you need to make sure you've all dependent jar files in your classpath.



来源:https://stackoverflow.com/questions/36586726/how-to-fix-noclassdeffounderror-circularoutputstream-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!