Search code examples
javaseleniumgsonselenium-grid

Getting java.lang.NoClassDefFoundError: com/google/gson/Gson


In my eclipse project (dynamic web project) I have the following structure:

enter image description here

And I use the Gson library. This a servlet project for the selenium node. The node runs on a linux machine. When I hit the servlet I get an error:

java.lang.NoClassDefFoundError: com/google/gson/Gson...

What am I missing? It works fine on windows.

Also here is an example command I use to start up a selenium node:

java -cp "selenium-server-standalone.jar:selenium-extras.jar" org.openqa.grid.selenium.GridLauncherV3 \ -servlets com.node.servlets.ExecuteServlet \ -role node \ -hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \ -maxSession 1 -browser $browserOpts

selenium-extras.jar is the servlet project.


Solution

  • The short answer is that the GSON jar file isn't on the classpath. Your classpath includes only two jar files: selenium-server-standalone.jar and selenium-extras.jar

    It works fine on windows

    From the information in this post (at the time of this writing) it is not really possible to tell why it works on Windows because you haven't included the command you use to start up a selenium node on Windows