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)

    0
      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
      • 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.CommentedMar 14, 2018 at 21:16
      • I have tried all versions of guava since 24.0-jre to 18.0 and no one works.CommentedMar 14, 2018 at 21:53
      • Have you checked that when you change the version in pom, this version is actually put into WEB-INF/lib folder?
        – adlerer
        CommentedMar 15, 2018 at 12:30
      • 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.pngCommentedMar 15, 2018 at 20:23
      • 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.
        – adlerer
        CommentedMar 17, 2018 at 14:37

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.