org.json.simple.parser.ParseException

4,833 views
Skip to first unread message

Ali

unread,
Aug 9, 2011, 4:26:35 PM8/9/11
to JsonPath
Hi there,
Just wondering, with only the jar file "json-path-0.5.3.jar", can we
start using JsonPath, or there should be other tools or plugins. I
downloaded the jar file and added to my project build path in eclipse.
Coding the follwoing, I don't get any compile error, but when I run
this, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/
simple/parser/ParseException
at f3Underf1.XPathExample.compareWithJsonPath(XPathExample.java:88)
at f3Underf1.XPathExample.main(XPathExample.java:57)
Caused by: java.lang.ClassNotFoundException:
org.json.simple.parser.ParseException
at java.net.URLClassLoader$1.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

My code is as simple as following:
[CODE]
String jsonString = "{\"store\":\"123\"}";
List<String> authors = JsonPath.read(jsonString, "$.store");
[/CODE]

Kalle Stenflo

unread,
Aug 10, 2011, 4:21:16 AM8/10/11
to json...@googlegroups.com
Hi,

If you use  Maven all dependencies will be included. If not, you need:


Regards
Kalle

Ali Sadri

unread,
Aug 10, 2011, 9:01:12 AM8/10/11
to json...@googlegroups.com
Thank you very much for your response. It worked very well.
Best Regards,
Ali Sadri.

Kavya Subramani

unread,
Sep 25, 2014, 3:23:45 PM9/25/14
to json...@googlegroups.com
I am facing the same issue.  I have the "json_simple-1.1.jar".  I have included it in the class path too, still i am facing the NoClassDefinition found exception.  Can you please help me with it.?

Kalle Stenflo

unread,
Sep 25, 2014, 3:59:42 PM9/25/14
to json...@googlegroups.com
Hi,

if you are using maven you just need to add this dependency.

<dependency>
    <groupId>com.jayway.jsonpath</groupId>
    <artifactId>json-path</artifactId>
    <version>0.9.1</version>
</dependency>
 
If not, below are links to jars you need.        
        

JsonPath does not use json_simple it uses json_smart.

Good luck
/Kalle

-- 
You received this message because you are subscribed to the Google Groups "JsonPath" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonpath+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhijeet Bhanjadeo

unread,
Jan 7, 2015, 3:07:53 AM1/7/15
to json...@googlegroups.com
This hit me yesterday, fews hrs lost due to this.

It's the maven (pom.xml) configuration, causing the confusion with the jar build. "json_simple-1.1.jar" has all the dependencies with in maven repository,
so just adding the dependency to pom.xml & updating project with maven dependencies should do it(Eclipse).

"maven-assembly-plugin" needs ordered before "maven-dependency-plugin"
& if you are making use of "maven-jar-plugin" then it's should be ordered before "maven-assembly-plugin".
i.e., maven-jar-plugin --> maven-assembly-plugin --> maven-dependency-plugin

Something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.version}</version>
<configuration>
 <archive>
<manifest>
<mainClass>com.Startup</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
 </archive>
 <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.assembly.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>com.Startup</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.dependency.version}</version>
<executions>
 <execution>
<id>copy-dependencies</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/dependency-jars/</outputDirectory>
</configuration>
 </execution>
</executions>
</plugin>



Thanks,
Abhijeet
Reply all
Reply to author
Forward
0 new messages