1
votes

Selenium - 3.10.0 Guava used as -

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>RELEASE</version>
</dependency>

Excluded all other guava dependencies.

How can this exception be resolved?

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector; 
    at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:306) 
    at org.openqa.selenium.MutableCapabilities.merge(MutableCapabilities.java:74) 
    at org.openqa.selenium.remote.DesiredCapabilities.merge(DesiredCapabilities.java:107)     
    at org.openqa.selenium.remote.DesiredCapabilities.merge(DesiredCapabilities.java:33) 
    at org.openqa.selenium.MutableCapabilities.setCapability(MutableCapabilities.java:97)

net.sourceforge.jtds:jtds:jar:1.3.1:compile
org.apache.httpcomponents:httpclient:jar:4.4.1:compile
com.hynnet:oracle-driver-ojdbc6:jar:12.1.0.1:compile
com.thoughtworks.paranamer:paranamer:jar:2.8:compile
xml-apis:xml-apis:jar:1.4.01:compile
org.slf4j:slf4j-log4j12:jar:1.7.5:compile
org.hdrhistogram:HdrHistogram:jar:1.2.1:compile
junit:junit:jar:4.12:compile org.hamcrest:hamcrest-core:jar:1.3:compile
org.mockito:mockito-core:jar:1.10.19:compile org.objenesis:objenesis:jar:2.1:compile
org.powermock:powermock-api-mockito:jar:1.6.2:compile
org.mockito:mockito-all:jar:1.10.19:compile org.powermock:powermock-api-support:jar:1.6.2:compile org.powermock:powermock-core:jar:1.6.2:compile org.powermock:powermock-reflect:jar:1.6.2:compile
org.powermock:powermock-module-junit4:jar:1.6.2:compile org.powermock:powermock-module-junit4-common:jar:1.6.2:compile
org.hamcrest:hamcrest-all:jar:1.3:compile
info.cukes:cucumber-java:jar:1.2.5:compile info.cukes:cucumber-core:jar:1.2.5:compile info.cukes:cucumber-html:jar:0.2.3:compile info.cukes:cucumber-jvm-deps:jar:1.0.5:compile info.cukes:gherkin:jar:2.12.2:compile
info.cukes:cucumber-junit:jar:1.2.5:compile
org.aspectj:aspectjrt:jar:1.8.3:compile
com.google.code.gson:gson:jar:2.8.0:compile
com.esotericsoftware.yamlbeans:yamlbeans:jar:1.11:compile
com.fasterxml.jackson.core:jackson-core:jar:2.5.4:compile
org.apache.logging.log4j:log4j-api:jar:2.8.2:compile
org.apache.logging.log4j:log4j-core:jar:2.8.2:compile
log4j:log4j:jar:1.2.17:compile
org.apache.commons:commons-lang3:jar:3.4:compile
commons-io:commons-io:jar:2.4:compile
org.quickfixj:quickfixj-core:jar:1.6.4:compile org.apache.mina:mina-core:jar:2.0.16:compile
javax.jms:jms:jar:1.2:compile net.sf.expectit:expectit-core:jar:0.8.2:compile
com.jcraft:jsch:jar:0.1.54:compile commons-lang:commons-lang:jar:2.6:compile org.apache.httpcomponents:fluent-hc:jar:4.5.3:compile org.apache.wink:wink-json4j:jar:1.4:compile org.apache.activemq:activemq-client:jar:5.14.5:compile com.hp.lft:sdk:jar:14.0.0:compile
com.hp.lft:sdk:jar:javadoc:14.0.0:compile
com.hp.lft:report:jar:14.0.0:compile
com.hp.lft:unittesting:jar:14.0.0:compile
com.hp.lft:verifications:jar:14.0.0:compile
com.hp.lft:reportbuilder:jar:14.0.0:compile
com.hp.lft:common:jar:14.0.0:compile
javax.ws.rs:javax.ws.rs-api:jar:2.0:compile
com.sun.jersey:jersey-client:jar:1.13:compile com.sun.jersey:jersey-core:jar:1.13:compile
org.glassfish.jersey.core:jersey-client:jar:2.8:compile
org.glassfish.jersey.core:jersey-common:jar:2.8:compile org.glassfish.jersey.bundles.repackaged:jersey-guava:jar:2.8:compile org.glassfish.hk2:osgi-resource-locator:jar:1.0.1:compile
org.glassfish.hk2:hk2-api:jar:2.2.0:compile org.glassfish.hk2:hk2-utils:jar:2.2.0:compile org.glassfish.hk2.external:aopalliance-repackaged:jar:2.2.0:compile
org.glassfish.hk2.external:javax.inject:jar:2.2.0:compile org.glassfish.hk2:hk2-locator:jar:2.2.0:compile org.javassist:javassist:jar:3.18.1-GA:compile org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.8:compile org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile org.codehaus.jackson:jackson-jaxrs:jar:1.9.13:compile org.codehaus.jackson:jackson-xc:jar:1.9.13:compile com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.7.3:compile org.yaml:snakeyaml:jar:1.15:compile com.fasterxml.jackson.core:jackson-databind:jar:2.5.4:compile com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile org.apache.logging.log4j:log4j-slf4j-impl:jar:2.1:compile org.slf4j:slf4j-api:jar:1.7.7:compile com.vimalselvam:cucumber-extentsreport:jar:2.0.1:compile com.aventstack:extentreports:jar:3.0.6:compile
org.freemarker:freemarker:jar:2.3.23:compile
org.mongodb:mongodb-driver:jar:3.3.0:compile
org.mongodb:bson:jar:3.3.0:compile org.mongodb:mongodb-driver-core:jar:3.3.0:compile
org.apache.httpcomponents:httpmime:jar:4.5.2:compile org.jsoup:jsoup:jar:1.9.2:compile com.relevantcodes:extentreports:jar:2.41.0:compile org.apache.poi:poi:jar:3.16:compile
commons-codec:commons-codec:jar:1.10:compile org.apache.commons:commons-collections4:jar:4.1:compile org.apache.poi:poi-ooxml:jar:3.16:compile
org.apache.poi:poi-ooxml-schemas:jar:3.16:compile com.github.virtuald:curvesapi:jar:1.04:compile org.apache.poi:ooxml-schemas:jar:1.3:compile org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile stax:stax-api:jar:1.0.1:compile org.ini4j:ini4j:jar:0.5.1:compile com.monitorjbl:xlsx-streamer:jar:1.2.0:compile xerces:xercesImpl:jar:2.11.0:compile org.seleniumhq.selenium:selenium-java:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-api:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-chrome-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-edge-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-firefox-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-ie-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-opera-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-safari-driver:jar:3.10.0:compile
org.seleniumhq.selenium:selenium-support:jar:3.10.0:compile
net.bytebuddy:byte-buddy:jar:1.7.9:compile
org.apache.commons:commons-exec:jar:1.3:compile
commons-logging:commons-logging:jar:1.2:compile
org.apache.httpcomponents:httpcore:jar:4.4.6:compile
com.squareup.okhttp3:okhttp:jar:3.9.1:compile com.squareup.okio:okio:jar:1.13.0:compile org.seleniumhq.selenium:selenium-server:jar:3.10.0:compile
com.beust:jcommander:jar:1.72:compile
org.apache.commons:commons-text:jar:1.1:compile
commons-net:commons-net:jar:3.6:compile
org.w3c.css:sac:jar:1.3:compile
net.sourceforge.cssparser:cssparser:jar:0.9.24:compile
net.sourceforge.htmlunit:htmlunit:jar:2.29:compile
net.sourceforge.htmlunit:htmlunit-core-js:jar:2.28:compile
net.sourceforge.htmlunit:neko-htmlunit:jar:2.28:compile
net.jcip:jcip-annotations:jar:1.0:compile
org.seleniumhq.selenium:jetty-repacked:jar:9.4.7.v20171121:compile
org.eclipse.jetty:jetty-client:jar:9.4.7.v20170914:compile
org.eclipse.jetty:jetty-http:jar:9.4.8.v20171121:compile
org.eclipse.jetty:jetty-io:jar:9.4.8.v20171121:compile
org.eclipse.jetty:jetty-util:jar:9.4.8.v20171121:compile
org.eclipse.jetty:jetty-xml:jar:9.4.7.v20170914:compile
org.seleniumhq.selenium:htmlunit-driver:jar:2.29.0:compile
javax.servlet:javax.servlet-api:jar:3.1.0:compile
org.eclipse.jetty.websocket:websocket-api:jar:9.4.7.v20170914:compile org.eclipse.jetty.websocket:websocket-client:jar:9.4.7.v20170914:compile org.eclipse.jetty.websocket:websocket-common:jar:9.4.7.v20170914:compile xalan:serializer:jar:2.7.2:compile xalan:xalan:jar:2.7.2:compile org.seleniumhq.selenium:selenium-remote-driver:jar:3.10.0:compile com.google.guava:guava:jar:23.6-jre:compile com.google.code.findbugs:jsr305:jar:1.3.9:compile org.checkerframework:checker-compat-qual:jar:2.0.0:compile com.google.errorprone:error_prone_annotations:jar:2.1.3:compile com.google.j2objc:j2objc-annotations:jar:1.1:compile org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile

3
No need to specifically add dependency for guava. It is automatically included in the selenium-java dependency. Search for guava in this selenium-java 3.10.0 pom.Grasshopper
Update the question with your code trial including the importsDebanjanB
@DebanjanB - Added all the jars from core framework and additional dependencies. If that's too much of info, I can edit it again with only local dependencies. I have excluded all the selenium/ guava jars from core framework in my pomShiekha Gurung
@Grasshopper - I tried - excluding all guava dependencies for selenium 3.10 and adding the RELEASE version. Also, I tried removing the guava dependency I had added. Still it shows error in both cases - java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.toImmutableList()Ljava/util/stream/Collector; at org.openqa.selenium.chrome.ChromeOptions.asMap(ChromeOptions.java:306)Shiekha Gurung

3 Answers

1
votes

Added this explicit dependency to my pom.xml fixed the issue for me.

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>25.0-jre</version>
</dependency>
0
votes

The error has been resolved for me. ChromeOptions class was referring to some other class containing toImmutableList() method (sdk jar in my case). Had to find out that particular jar by checking the referred jar and excluding it from the pom dependencies. This resolved the issue

-1
votes

In my Gradle project I fixed it by adding this dependency:

   compile 'com.google.guava:guava:25.+'

Apparently, something else was overriding it until I explicitly set it