问题
I have encountered the following error "Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonParseException", when running selenium script in TestNg. How to resolve this error?
回答1:
I have came across the same "NoClassDefFoundError:com/google/gson/JsonParseException" error before. This was caused by the addition of "selenium-java-2.53.0" jar file in my package.
I removed this jar file and refreshed my project and ran again. It was working fine there after.
You can try the same. The version of the jar file may differ but removing it should do the job.
Cheers.
回答2:
I was facing the same problem. The error is due to the conflicting version on gson. I was able to overcome this by removing the maven dependency and deleting the jar from maven repository.
Cheers
来源:https://stackoverflow.com/questions/44645859/exception-in-thread-main-java-lang-noclassdeffounderror-com-google-gson-jsonp