selenium-server grid2 start problem. NoClassDefFoundError exception

佐手、 提交于 2020-01-06 04:56:08

问题


java -jar selenium-server-2.1.0.jar -role rc -hub http://localhost:4444/grid/register -port 5555

2.8.2011 12:14:12 org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONExceptio
n
        at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:57)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 1 more

回答1:


You need to use the selenium-server-standalone-2.X.Y.jar in order to get all the necessary libs. The selenium-server-2.X.Y.jar is only if you intend to manage your own classpath.




回答2:


I have the same problem. Things I've tried so far:

  1. Include the Selenium-2.3.0/libs folder in my classpath environment variable
  2. Include the Selenium-2.3.0/libs folder with a command line override "-classpath /path/libs/*"
  3. Add json.jar (with JSONException.class in org/json folder) to my jre's ext folder and made sure it's on the classpath
  4. Written my own MyTest.java class (code below), compiled it and run it without problems
    import org.json.JSONException;

    public class MyTest {
      public static void main(String[] args) {
        new JSONException("message");
      }
    }

So what's next?




回答3:


For ppl working on selenium and are new to selenium. Download latest Selenium Standalone Server jar file from http://docs.seleniumhq.org/download/ Right click on project--> Build Path-->Configure Build Path.. Here in Java Build Path section, goto Libraries tab and click on "Add External Jars" button Now, add the above jar file downloaded here.click Apply and then OK.

this resolved the issue for me.




回答4:


As nirvdrum mentioned, unless you want to manage your classpath I would recommend using the selenium standalone server JAR file.

for the hub use:

java -jar selenium-server-standalone-2.3.0.jar -role hub

for a node on the same machine:

java -jar selnium-server-standalone-2.3.0.jar -role remotecontrol -hub http://localhost:4444/grid/register -port [XXXX] (something other than 4444)

This is just to get your grid setup. In order for you to use run a test through the grid you would need to use a RemoteWebDriver instance that references your hub. For example:

WebDriver driver = new RemoteWebDriver( new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox() );


来源:https://stackoverflow.com/questions/6910488/selenium-server-grid2-start-problem-noclassdeffounderror-exception

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