I'm just trying to get setup and have the ability to run the example from Selenium's website. However I've narrowed it down to the FirefoxDriver constructor causing a StackOverflowError. I get the same behavior with InternetExplorerDriver, but not HtmlUnitDriver.
The following code
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class WebDriverTest {
@Test
public void test() {
WebDriver driver = new FirefoxDriver();
}
}
Produces the following stacktrace:
java.lang.StackOverflowError
at java.lang.Exception.<init>(Unknown Source)
at java.lang.reflect.InvocationTargetException.<init>(Unknown Source)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.json.JSONObject.populateMap(JSONObject.java:937)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1539)
at org.json.JSONObject.populateMap(JSONObject.java:939)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1539)
at org.json.JSONObject.populateMap(JSONObject.java:939)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1539)
at org.json.JSONObject.populateMap(JSONObject.java:939)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1539)
at org.json.JSONObject.populateMap(JSONObject.java:939)
at org.json.JSONObject.<init>(JSONObject.java:272)
at org.json.JSONObject.wrap(JSONObject.java:1539)
at org.json.JSONObject.populateMap(JSONObject.java:939)
at org.json.JSONObject.<init>(JSONObject.java:272)
:
:
I'm using selenium-java-2.22.0 and the json jar that was packaged with the download (which is json-20080701.jar)
Also of note, when running the new FirefoxDriver, Firefox does launch and you see a new tab page. With InternetExplorerDriver, no window opens, but it produces the same stacktrace with JSONObject looping infinitely. I'm running Firefox 12.0 and IE9 on Windows 7.
A stack overflow is a type of buffer overflow error that occurs when a computer program tries to use more memory space in the call stack than has been allocated to that stack.
The most common cause of StackOverFlowError is excessively deep or infinite recursion. In Java: There are two areas in memory the heap and stack.
The error java. lang. StackOverflowError is thrown to indicate that the application's stack was exhausted, due to deep recursion i.e your program/script recurses too deeply.
Some of the JAR files in your classpath are conflicting with Selenium dependencies. It is kinda strange that it happened even though you are using Ivy. One of your dependencies most likely includes the conflicting classes inside its jar file - or your dependencies need two different versions of the same library.
Anyway, for future user reading this - use some dependency manager to do the hard work with jars for you. Don't try to maintain your libraries manually if you have more that 10 projects with dependencies - you'll most likely screw it up soon. This is quite a reasonable read on dependency solutions, follow some of the links there, don't be lazy. Dependency managers take some time to master, they are a world for themselves. But they help a lot.
Don't use multiple versions of the same library. And if you use multiple libraries from which two use a different version of the same thing ... good luck to you!
Other than that ... our only hope is Java Module System which will be introduced in Java 8 Java 9.
We are hitting this as well, and I can confirm that you encounter this if your test project has org.json classes of other/older versions than the ones WebDriver needs (20080701) somewhere on its classpath.
PS: FTR I've opened http://code.google.com/p/selenium/issues/detail?id=4123 "by mistake", so just to clarify that this is NOT A WEBDRIVER ISSUE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With