Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't be used in hive-0.11: java.lang.NoClassDefFoundError #77

Closed
ericxsun opened this issue Mar 29, 2015 · 15 comments
Closed

Can't be used in hive-0.11: java.lang.NoClassDefFoundError #77

ericxsun opened this issue Mar 29, 2015 · 15 comments
Labels

Comments

@ericxsun
Copy link

The pom.xml was set according to your DOC: Getting Started.

I run it in my laptop, it works well. However, when run it on hive 0.11, error occurred:

Caused by: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI
at com.jayway.jsonpath.internal.DefaultsImpl.(DefaultsImpl.java:17)
at com.jayway.jsonpath.internal.DefaultsImpl.(DefaultsImpl.java:15)
at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:53)
at com.jayway.jsonpath.Configuration.defaultConfiguration(Configuration.java:178)
at com.jayway.jsonpath.internal.JsonReader.(JsonReader.java:48)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:461)
at com.qunar.hive.udf.ParseJsonWithPath.evaluate(ParseJsonWithPath.java:64)
... 26 more
Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReaderI
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 33 more

Could anybody help me? Thanks a lot.

@kallestenflo
Copy link
Contributor

Looks like you missing dependencies on your classpath.

Try adding:

'net.minidev:json-smart:2.1.1'
'org.slf4j:slf4j-api:1.7.10'

@ericxsun
Copy link
Author

Thanks a lot. I add the dependencies on my classpath following http://mvnrepository.com/artifact/com.jayway.jsonpath/json-path/2.0.0

(
com.fasterxml.jackson.core jackson-databind 2.4.5
com.google.code.gson gson 2.3.1
net.minidev json-smart 2.1.1
org.slf4j slf4j-api 1.7.10
)

A new error happened where querying on hive:
Caused by: java.lang.NoClassDefFoundError: com/jayway/jsonpath/Predicate
at com.qunar.hive.udf.ParseJsonWithPath.evaluate(ParseJsonWithPath.java:58)
... 26 more
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.Predicate
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Appreciate your help.

@ericxsun ericxsun changed the title Can't used in hive-0.11: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI Can't be used in hive-0.11: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI Mar 30, 2015
@ericxsun ericxsun changed the title Can't be used in hive-0.11: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI Can't be used in hive-0.11: java.lang.NoClassDefFoundError Mar 30, 2015
@kallestenflo
Copy link
Contributor

Sorry, you also need asm-1.0.2.jar (json-smart dependency). Download the zip/tar with all dependencies here https://github.com/jayway/JsonPath/releases/tag/json-path-2.0.0. All jars under the lib folder are mandatory (if you use the default JsonSmartJsonProvider)

@ericxsun
Copy link
Author

Thansk. But the same error occurred again.

.....
Caused by: java.lang.ClassNotFoundException: com.jayway.jsonpath.Predicate
....

@kallestenflo
Copy link
Contributor

If you have the following jars on your classpath you're problem lies elsewhere.
'net.minidev:json-smart:2.1.1'
'net.minidev:asm:2.1.1'
'org.slf4j:slf4j-api:1.7.10'
'com.jayway.jsonpath:json-path:2.0.0'
could it be you have multiple versions of jsonpath on CP? I don't know Hive.

@ericxsun
Copy link
Author

ericxsun commented Apr 1, 2015

Finally OK.

Using:
'net.minidev:json-smart:2.1.1'
'net.minidev:asm:1.0.2'
'org.slf4j:slf4j-api:1.7.10'
'com.jayway.jsonpath:json-path:2.0.0'

Thank you very much.

@zkendall
Copy link

Why aren't these dependencies included?
Shouldn't I only need to depend on json-path?

@kallestenflo
Copy link
Contributor

They are if you use maven or gradle.

Sent from my iPhone

On 13 jan. 2016, at 19:37, Zachariah Kendall notifications@github.com wrote:

Why aren't these dependencies included?
Shouldn't I only need to depend on json-path?


Reply to this email directly or view it on GitHub.

@zkendall
Copy link

I'm using maven. Had to explicitly define them.

@kallestenflo
Copy link
Contributor

I just tested this again and it works. Does the attached project build?
test-jp.zip

@kallestenflo
Copy link
Contributor

@zkendall could you please verify if attached project builds.

@zkendall
Copy link

That worked fine.

@zkendall
Copy link

More details about my situation. I have a dependency on RestAssured.

            <groupId>com.jayway.restassured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>${rest-assured.version}</version>
            <scope>test</scope>

Which has a dependency on JsonPath. My IDE seemed to think everything was cool. But in run-time, I got NoClassDefFoundError.

To solve this, I had to add json-path and json-path-assert and json-smart (net.minidev) dependencies.

@JaguarXF
Copy link

I removed json-path version 0.9.1 and replaced it with json-path version 2.0.0 and this seemed to work for me.

@fuguanqi
Copy link

fuguanqi commented Jan 8, 2019

I was caught in the same problem when writing a UDTF parsing json. My solution was to put the jar package in path:$HIVE_HOME/lib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants