Question

Hi I am currently using the JodaTime library in my NetBeans restful web services on GlassFish Server using Jackson libraries.

I get a java.lang.NoClassDefFoundError for org/joda/time/ReadablePartial when I try to create an instance of a class that uses the JodaTime library in one of the Resource files. E.g:

In the studentResource file:

     Controller c = new Controller();

Where the Controller class imports and uses JodaTime libraries

I have checked that the libraries I needed are in the project. In fact, if I run a separate project outside of the restful web services, everything runs smoothly. Is there an additional classpath issue that I have to address?

Was it helpful?

Solution 3

Ok I found the solution. Apparently all I needed to do was to move the jar file up in the list of libraries/jar files. I do that in the library tab in the project's properties. More specifically, the jar file has to be moved above the REST libraries.

OTHER TIPS

In case someone stumbles upon the same problem using Spring:

This problem comes up if you are trying to map JSON to a Java object using Jackson either via @RequestBody annotation on controller parameter or manually deserializing using an ObjectMapper().readValue(json, Class.class). Everything works fine on local machine but when deploying application to GlassFish deserialization fails.

Keeg's workaround to copy Joda-Time.jar to glassfish/modules and restarting fixes the issue.

There seems to be a bug open on Jira about this issue: https://java.net/jira/browse/GLASSFISH-20808

Just in case someone else stumbles upon this problem, we had a similar issue with the combination of Glassfish 3.1.1, Jersey and use of Joda time. Stacktraces like this:

Caused by: java.lang.ClassNotFoundException: org.joda.time.ReadableInstant not found by jackson-mapper-asl [128]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)

etc.

The workaround I just found was dumping a copy of our joda-time jar into glassfish/modules. Not exactly pretty, but...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top