0

Im getting this error

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)

Im building a bot for social media , so Im using Selenium libraries, and the bot works fine on a Java Application , but when I copy the code to a Web Application where I have a Servlet listening to my Android application , when I run the servlet , and the servlet calls the code of the bot that use Selenium, it throws that error when it comes to that line

System.setProperty("webdriver.chrome.driver", "C:\\Users\\manue\\OneDrive\\Escritorio\\chromedriver.exe");
    driver = new ChromeDriver();

I had read that it can be becouse of the version of guava that I have , but my version of guava is updated , and I dont know why Im getting this error.

In my maven pom.xml I have the dependencies like this

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.10.0</version>
    </dependency>

Here there is a screenshot of the structure of my project. screenshot of my project

2 Answers 2

2

I found a solution to a possibly related error message when I removed the Google Collections jar from the lib path.

(Source)

Sign up to request clarification or add additional context in comments.

Comments

1

Looks like a classpath issue. What version of guava-X.jar do you have in our classpath? (most probably in WEB-INF/lib of webapp). Possible solution is to declare latest version of guava in your pom.xml explicitly. For 3.10.0 of selenium, you need:

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>24.0-jre</version>
</dependency>

9 Comments

Im using guava-23.6-jre, I have tried adding this dependency and it update me to guava 24.0-jre but still dont working.
I have tried all versions of guava since 24.0-jre to 18.0 and no one works.
Have you checked that when you change the version in pom, this version is actually put into WEB-INF/lib folder?
My WEB-INF folder is empty , there is not any lib folder inside. Im going to upload a screenshot of the structure of my project. i.sstatic.net/ydaiS.png
Yes, it's empty because these are the sources. Once you project is built and is deployed to server (tomcat? - to webapps folder), then it should be most probably packaged as project.war file. It's a zip archive - if you rename it to project.zip and then unpack, you should see a lib folder in the WEB-INF one.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.