java.lang.NoSuchMethodError

726 views
Skip to first unread message

arbn...@gmail.com

unread,
Jun 9, 2017, 2:38:59 AM6/9/17
to Selenium Users
Hi,

I am trying to launch a selenium in a java web application. The test methods are in same project with web app, in folder src/test/java.

Here is my code that throws the exception:

@BeforeClass
public static void setUp() throws SQLException, Exception
{
File file = new File(driverPath);
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
webDriver = new ChromeDriver(); //this line is throwing the exception
webDriver.get("https://localhost/myApp/");
}

Exception:
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.toImmutableSet()Ljava/util/stream/Collector;
at org.openqa.selenium.remote.ProtocolHandshake.streamW3CProtocolParameters(ProtocolHandshake.java:284)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:149)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at setup.Setup.setUp(Setup.java:46)
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 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:166)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)
Suppressed: java.io.IOException: Incomplete document
at com.google.gson.stream.JsonWriter.close(JsonWriter.java:544)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:167)
... 35 more


p.s. When I launch the selenium test in different project, it works well.

Krishnan Mahadevan

unread,
Jun 9, 2017, 2:40:59 AM6/9/17
to seleniu...@googlegroups.com

How is your CLASSPATH configured ? Can you please let us know that ? You might want to share the relevant build.gradle/pom.xml/build.xml based on the flavor of your build tool.

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0dd27450-e3b9-49c7-9cca-78fb421ecab4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

arbn...@gmail.com

unread,
Jun 9, 2017, 3:47:51 AM6/9/17
to Selenium Users
Thanks for your reply.

Here is my classpath:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="selenium"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/sqljdbc42.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/gson-2.4.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/client-combined-3.4.0-nodeps.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/httpclient-4.5.3.jar"/>
<classpathentry kind="con" path="net.sf.jasperreports.JR_CONTAINER"/>
<classpathentry kind="con" path="net.sf.jasperreports.JR_DEPENDENCIES_CONTAINER"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/httpcore-4.4.6.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/cglib-nodep-3.2.4.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/commons-exec-1.3.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/commons-io-2.5.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/commons-lang3-3.5.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/cssparser-0.9.22.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/guava-21.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/hamcrest-core-1.3.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/htmlunit-2.26.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/htmlunit-core-js-2.26.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/htmlunit-driver-2.26.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/httpmime-4.5.3.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/javax.servlet-api-3.1.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/jetty-io-9.4.1.v20170120.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/jetty-util-9.4.1.v20170120.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/jna-4.1.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/jna-platform-4.1.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/junit-4.12.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/neko-htmlunit-2.25.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/phantomjsdriver-1.4.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/sac-1.3.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/serializer-2.7.2.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/websocket-api-9.4.3.v20170317.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/websocket-client-9.4.3.v20170317.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/websocket-common-9.4.3.v20170317.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/xalan-2.7.2.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/xercesImpl-2.11.0.jar"/>
<classpathentry kind="lib" path="../selenium-java-3.4.0/lib/xml-apis-1.4.01.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

Krishnan Mahadevan

unread,
Jun 9, 2017, 4:28:18 AM6/9/17
to seleniu...@googlegroups.com

How are you building your code ? Is it a maven project or a gradle one ? I was hoping you could share that instead of the classpath file generated by eclipse.

arbn...@gmail.com

unread,
Jun 9, 2017, 4:33:41 AM6/9/17
to Selenium Users
Actually currently I'm not using any building tool.
Reply all
Reply to author
Forward
0 new messages