我正在使用Selenium 2.24.1,我收到此错误:
Caused an ERROR
null
java.lang.StackOverflowError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.json.JSONObject.populateMap(JSONObject.java:988)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1587)
at org.json.JSONObject.populateMap(JSONObject.java:990)
at org.json.JSONObject.<init>(JSONObject.java:272)
我不确定我缺少什么,我有json-20080701.jar,并且所有jar文件都带有selenium-java-2.24.1和selenium-server-2.24.1。
即使只使用selenium-server-standalone-2.24.1.jar,我仍然会收到此错误消息。
有什么帮助吗?
答案 0 :(得分:3)
我很确定你有一个带有循环依赖关系的Object图。
以下是一个例子:
public class Parent{
private List<Child> children;
}
public class Child{
private Parent parent;
}
如果你试图将其序列化为JSON,除非你的算法知道循环依赖,否则你也会得到一个StackOverflow。
因为对于每个父母,都必须创建一个孩子列表,每个孩子都有一个父母,每个孩子都有一个孩子的列表等等。
答案 1 :(得分:1)
您的项目看起来像其他/旧版本的org.json类而不是WebDriver在其类路径上需要的版本。并且您的json版本不适用于WebDriver。
如果你检查你的selenium-server-standalone-x.xx.x.jar,你会发现包含了org.json。
这意味着该项目在其类路径上有两个不同版本的json jar。
欢迎来到JAR地狱。
解决方案: 将json库替换为位于/Selenium-x.xx/lib/json-20080701.jar中的selenium库