3

I am new to Json-Path.

I have included: json-path-0.8.0.jar in my eclipse build path.

I copied JSON from: http://code.google.com/p/json-path/ to file.

and I am trying to parse this file and display an authors name using:

String jsonPath = "$.store.book[1].author";
File jsonFile = new File("C:\\ServicesTest\\jsonresponse2.json");
System.out.println("Author: "+JsonPath.read(jsonFile, jsonPath));

I am getting this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/Validate
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:304)
at office.jsonPathparse.main(jsonPathparse.java:34)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.Validate
at java.net.URLClassLoader1ドル.run(Unknown Source)
at java.net.URLClassLoader1ドル.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more

I have also inculded: org.apache.commons.lang-2.6.jar But I am still getting the error. Am I missing something here ?

Found the problem: I have to add following jar's to path:

json-path-0.8.0.jar

commons-lang-2.6.jar

commons-io-2.1.jar

json-smart-1.1.jar

I was missing the last 2.

asked Aug 30, 2013 at 19:04

1 Answer 1

4

You may be missing the import statements, or the library jar file is not actually added to your classpath correctly. NoClassDefFoundError means java can't find the class that is referenced in your code...

answered Aug 30, 2013 at 19:26
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks SnakeDoc. I just checked I was missing the dependency files. Had to open up the jar to realise that. Thanks.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.