Creating a new WebDriver causes StackOverflowError
selenium, selenium-webdriver, webdriver
Solution
Welcome to JAR hell
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.
Problem
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.