Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder; while launching Chrome through ChromeDriver

Ask Question

Hi I am facing this issue while launching the driver.

Starting ChromeDriver 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73) on port 4097
Only local connections are allowed.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
    at org.openqa.selenium.json.Json.<clinit>(Json.java:47)
    at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.constructMessage(HttpProfilerLogEntry.java:37)
    at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.<init>(HttpProfilerLogEntry.java:29)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
    at isf.Login.main(Login.java:21)

Can anybody tell what i am missing ..because same libs i am using for another project and its working fine there.

Do update the question with the version information of the binaries you are using as in SeleniumJavaClient and Chrome – undetected Selenium May 29, 2018 at 15:40

I was facing the same issue and got resolved using below approach: If you check JSON class at line 47, setLenient() is missing.

This issue is possibly due to conflicts in Gson versions.

Go to your repository:

C:\Users\User_name\.m2\repository\com\google\code\gson

Delete all the existing folders.

Now, add below maven dependency in your pom file:

<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.5</version>
    <scope>provided</scope>
</dependency>

Re-build your pom.xml file and execute the script.

This solved my issue on a Mac. Thanks! cd /.m2/repository/com/google/code/gson rm -rf gson* Then add the dependency. I had to add the dependency. It didn't work until I did that. – Doug Noel Jun 27, 2018 at 17:54

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.