Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 779
Romita Thakur Avatar asked May 29 '18 14:05

Romita Thakur


1 Answers

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.

like image 86
jitendra.khedar Avatar answered Nov 18 '22 19:11

jitendra.khedar