ClassNotFoundException when using initializing Appiumdriver

1,277 views
Skip to first unread message

Build Jenkins

unread,
Jun 17, 2014, 5:37:35 AM6/17/14
to appium-...@googlegroups.com, antho...@autodesk.com
Hi, 
I'm new to this so please bear with me.

I'm trying to run Appium on Java. I have the server running on the Appium UI Version 1.1.0 (Cygnus) - the inspector and the iOS simulator works fine.

When i try to run my java tests, the simulator launches correctly and the app is loaded.
However, when moving on to the actual tests, i get the following error on the console:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/JsonParser

at io.appium.java_client.ComplexFind.<clinit>(ComplexFind.java:16)

at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:46)

at com.newtest.Test1.main(Test1.java:23)

Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonParser

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

... 3 more



Line 23 is where:  AppiumDriver wd = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

I have linked the selenium jar files and the Appium Java client with the project already.



Could anyone kindly help? Please.

Vinu Joseph

unread,
Jun 17, 2014, 8:28:33 AM6/17/14
to appium-...@googlegroups.com, antho...@autodesk.com
Hi,
It looks like your .java files have not been compiled.

Use command prompt and go to the .java file(Eg. test.java) location which you want to run.

run 'javac test.java'

After compiling your .java files try to run your testcase. It should be able to run.

Build Jenkins

unread,
Jun 17, 2014, 11:19:50 PM6/17/14
to appium-...@googlegroups.com, antho...@autodesk.com
Hi Vinu,

I'm writing the test using Eclipse and have already linked the .jar files necessary.

Build Jenkins

unread,
Jun 18, 2014, 1:41:44 AM6/18/14
to appium-...@googlegroups.com, antho...@autodesk.com
I've managed to solve this by using

WebDriver wd = new RemoteWebDriver;
Instead of
AppiumDriver wd = new AppiumDriver;

And of course importing
import org.openqa.selenium.WebDriver;
instead of
import io.appium.java_client.AppiumDriver;



Does this impact the appium functionality?
What differences are there, if any?

http://thebuddhatree.blogspot.in/

unread,
Jun 18, 2014, 2:04:37 AM6/18/14
to appium-...@googlegroups.com, antho...@autodesk.com
Technically speaking No. Actually, AppiumDriver extends RemoteWebDriver

Build Jenkins

unread,
Jun 18, 2014, 2:44:56 AM6/18/14
to appium-...@googlegroups.com, antho...@autodesk.com
Alright, thanks for the info.

Any idea why it fails when I use AppiumDriver?
T.T

Sravan Kumar

unread,
Jun 18, 2014, 2:46:40 AM6/18/14
to appium-...@googlegroups.com, antho...@autodesk.com

Hi ,

Adding gson.jar to classpath will solve your problem, which does to me.

Build Jenkins

unread,
Jun 18, 2014, 2:53:24 AM6/18/14
to appium-...@googlegroups.com, antho...@autodesk.com
YOU'RE RIGHT!!
Thanks a ton Sravan.

Man, did I miss it or is this not documented?

Isaac Murchie

unread,
Jun 18, 2014, 9:56:24 AM6/18/14
to Build Jenkins, appium-...@googlegroups.com, antho...@autodesk.com
It should be automatically installed if you're using Maven. See https://github.com/appium/java-client/blob/master/pom.xml#L11



--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages