users@jersey.java.net

Re: [Jersey] java.lang.ClassNotFoundException: com.sun.jersey.json.impl.JSONUnmarshaller

From: Cheng Zhang <zhangyongjiang_at_yahoo.com>
Date: Sat, 8 Aug 2009 07:48:32 -0700 (PDT)

The code I'm running is some unit test code. I was using Grizzly to do the unit test. The problem disappeared after I switched to embedded GlassFish. Our runtime environment is tomcat. There is no problem either. So I guess there might be some problem with the Grizzly.

Thanks,

-Kevin




________________________________
From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
To: users_at_jersey.dev.java.net
Sent: Saturday, August 8, 2009 4:58:11 AM
Subject: Re: [Jersey] java.lang.ClassNotFoundException: com.sun.jersey.json.impl.JSONUnmarshaller

Hi,

What is the following class doing:

  yjava.ws.util.jaxb.JAXBContextWrapper

? can you share the code ? (feel free to send me it privately if you do not want to send to the public list).

Do you have a ContextResolver<JAXBContext> in your application ?

I am wondering if you compiled some Java source using Jersey 1.1.0-ea and are reusing those classes with Jersey 1.1.1-ea. For 1.1.1-ea we refactored the JSON JAXB code to make it reusable, thus the class com.sun.jersey.json.impl.JSONUnmarshaller was refactored to become com.sun.jersey.api.json.JSONUnmarshaller:

  https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/json/JSONUnmarshaller.html
  https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/json/JSONJAXBContext.html

Paul.


On Aug 7, 2009, at 7:45 PM, Cheng Zhang wrote:

> Hello,
>
> I just started my first Jersey application and got an exception below.
>
> <![CDATA[java.lang.NoClassDefFoundError: com/sun/jersey/json/impl/JSONUnmarshaller
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
> at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at yjava.ws.util.jaxb.JAXBContextWrapper.createUnmarshaller(JAXBContextWrapper.java:154)
> at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:115)
> at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getUnmarshaller(AbstractJAXBProvider.java:98)
> at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.readFrom(AbstractRootElementProvider.java:97)
> at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:519)
> at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:480)
> at com.sun.jersey.api.client.WebResource.handle(WebResource.java:561)
> at com.sun.jersey.api.client.WebResource.get(WebResource.java:179)
> at com.yahoo.sla.rest.PipelineAndGroupTest.testGroup(PipelineAndGroupTest.java:83)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
> at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
> at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
> at org.testng.TestRunner.runWorkers(TestRunner.java:712)
> at org.testng.TestRunner.privateRun(TestRunner.java:582)
> at org.testng.TestRunner.run(TestRunner.java:477)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
> at org.testng.SuiteRunner.run(SuiteRunner.java:198)
> at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:788)
> at org.testng.TestNG.run(TestNG.java:708)
> at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62)
> at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
> at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
> Caused by: java.lang.ClassNotFoundException: com.sun.jersey.json.impl.JSONUnmarshaller
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> ... 50 more
> ]]>
> </full-stacktrace>
>
>
> Part of my maven pom file is as below,
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-core</artifactId>
> <version>1.1.1-ea</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-json</artifactId>
> <version>1.1.1-ea</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>1.1.1-ea</version>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-client</artifactId>
> <version>1.1.1-ea</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey.test.framework</groupId>
> <artifactId>jersey-test-framework</artifactId>
> <version>1.1.1-ea</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.grizzly</groupId>
> <artifactId>grizzly-servlet-webserver</artifactId>
> <version>1.9.8</version>
> <scope>test</scope>
> </dependency>
>
> Client side code throws the NoClassDefFoundError error:
>
> PipelineGroup response = webResource.path("group").path("1")
> .accept(MediaType.APPLICATION_XML)
> .get(PipelineGroup.class);
>
> If I change the client side code to below, no exception and response is xml string representation of my object
>
> String response = webResource.path("group").path("1")
> .get(String.class);
>
> Any idea?
>
> Thanks a lot,
> Kevin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net