users@jersey.java.net

Re: [Jersey] JSON/JAXB Exception in Jersey 1.0.2

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 18 Feb 2009 10:34:02 +0100

Hi Mark,

My guess is that Weblogic is somehow forcing the Web application to
use a lesser version of JAXB than the 2.1.10 version you have included
in the war.

 From Jakub's blog there is an entry that states:

   Switching to jaxb-impl-2.1.10 worked for me. I think in your case
Weblogic still loading ContextFactory from the old jar file.
   To trace where it loads from add "-verbose" to java command that
launches Weblogic and then search for ContextFactory.

can you try that?

Would it be possible to give a quick try using say Tomcat or Glassfish
to see if it is a Weblogic deployment issue?

Thanks,
Paul.

On Feb 17, 2009, at 10:45 PM, Rabick, Mark A (MS) wrote:

> Jakub's blogpost on configuring JSON for Jersey 1.0.2 introduced the
> "NATURAL" JSON notation:
>
> http://blogs.sun.com/japod/entry/configuring_json_for_restful_web
>
> I modified my provider class as follows:
>
> @Provider
> public final class JAXBContextResolver implements
> ContextResolver<JAXBContext> {
>
> private final JAXBContext context;
>
> private final Set<Class> types;
>
> private final Class[] cTypes = {ToyNode.class, Node.class};
>
> public JAXBContextResolver() throws Exception {
>
> this.types = new HashSet(Arrays.asList(cTypes));
> this.context = new JSONJAXBContext(
> JSONConfiguration.natural().build(), cTypes);
> }
>
> public JAXBContext getContext(Class<?> objectType) {
> return (types.contains(objectType)) ? context : null;
> }
>
> I get an exception when the application deploys similar to the one
> referenced in the comments at the blog post. I downloaded the http://download.java.net/maven/1/com.sun.xml.bind/jars/jaxb-impl-2.1.10.jar
> and still get the exception when my app deploys. Using Weblogic
> 10.0, Java 1.5.0_17 and Jersey 1.0.2 distribution files from http://download.java.net/maven/2/com/sun/jersey/jersey-archive/1.0.2/jersey-archive-1.0.2.zip
> .
>
> I went through the dependencies document and retrieved the remaining
> jars listed for JAXB. Please advise. The stacktrace is here:
>
> Feb 17, 2009 3:07:11 PM
> com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Provider classes found:
> class mil.cnodb.rs.config.EJBProvider
> class mil.cnodb.rs.config.JAXBContextResolver
> Feb 17, 2009 3:07:12 PM
> com.sun.jersey.core.spi.component.ProviderFactory
> _getComponentProvider
> SEVERE: The provider class, class
> mil.cnodb.rs.config.JAXBContextResolver, could not be instantiated
> javax.xml.bind.JAXBException: property "retainReferenceToInfo" is
> not supported
> at
> com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
> 52)
> 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:585)
> at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
> at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
> at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
> at
> com.sun.jersey.api.json.JSONJAXBContext.<init>(JSONJAXBContext.java:
> 256)
> at
> mil
> .cnodb.rs.config.JAXBContextResolver.<init>(JAXBContextResolver.java:
> 39)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
> at
> sun
> .reflect
> .NativeConstructorAccessorImpl
> .newInstance(NativeConstructorAccessorImpl.java:39)
> at
> sun
> .reflect
> .DelegatingConstructorAccessorImpl
> .newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
> at java.lang.Class.newInstance0(Class.java:350)
> at java.lang.Class.newInstance(Class.java:303)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .component
> .ComponentConstructor._getInstance(ComponentConstructor.java:154)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .component
> .ComponentConstructor.getInstance(ComponentConstructor.java:143)
> at
> com
> .sun
> .jersey
> .core.spi.component.ProviderFactory.getInstance(ProviderFactory.java:
> 206)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .component
> .ProviderFactory._getComponentProvider(ProviderFactory.java:133)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .component.ProviderFactory.getComponentProvider(ProviderFactory.java:
> 126)
> at
> com
> .sun
> .jersey
> .core
> .spi.component.ProviderServices.getComponent(ProviderServices.java:
> 168)
> at
> com
> .sun
> .jersey
> .core
> .spi.component.ProviderServices.getProviders(ProviderServices.java:95)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .factory.ContextResolverFactory.<init>(ContextResolverFactory.java:90)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:410)
> at
> com
> .sun
> .jersey
> .server
> .impl
> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:317)
> at
> com
> .sun
> .jersey
> .spi.container.servlet.WebComponent.initiate(WebComponent.java:422)
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.load(WebComponent.java:433)
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.init(WebComponent.java:167)
> at
> com
> .sun
> .jersey
> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
> 197)
> at weblogic.servlet.internal.StubSecurityHelper
> $ServletInitAction.run(StubSecurityHelper.java:282)
> at
> weblogic
> .security
> .acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
> at weblogic.security.service.SecurityManager.runAs(Unknown Source)
> at
> weblogic
> .servlet
> .internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:63)
> at
> weblogic
> .servlet
> .internal
> .StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
> at
> weblogic
> .servlet
> .internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
> at
> weblogic
> .servlet
> .internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:507)
> at
> weblogic
> .servlet
> .internal
> .WebAppServletContext.preloadServlet(WebAppServletContext.java:1853)
> at
> weblogic
> .servlet
> .internal
> .WebAppServletContext
> .loadServletsOnStartup(WebAppServletContext.java:1830)
> at
> weblogic
> .servlet
> .internal
> .WebAppServletContext.preloadResources(WebAppServletContext.java:1750)
> at
> weblogic
> .servlet
> .internal.WebAppServletContext.start(WebAppServletContext.java:2909)
> at
> weblogic
> .servlet.internal.WebAppModule.startContexts(WebAppModule.java:973)
> at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:361)
> at weblogic.application.internal.flow.ModuleStateDriver
> $3.next(ModuleStateDriver.java:204)
> at
> weblogic
> .application
> .utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
> at
> weblogic
> .application
> .internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
> at
> weblogic
> .application
> .internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
> at
> weblogic
> .application
> .internal
> .flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:117)
> at weblogic.application.internal.flow.ModuleStateDriver
> $3.next(ModuleStateDriver.java:204)
> at
> weblogic
> .application
> .utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
> at
> weblogic
> .application
> .internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
> at
> weblogic
> .application
> .internal.flow.StartModulesFlow.activate(StartModulesFlow.java:26)
> at weblogic.application.internal.BaseDeployment
> $2.next(BaseDeployment.java:635)
> at
> weblogic
> .application
> .utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
> at
> weblogic
> .application.internal.BaseDeployment.activate(BaseDeployment.java:212)
> at
> weblogic
> .application
> .internal
> .DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
> at
> weblogic
> .deploy
> .internal
> .targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:
> 80)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .operations.AbstractOperation.activate(AbstractOperation.java:566)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .operations
> .ActivateOperation.activateDeployment(ActivateOperation.java:136)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .operations.ActivateOperation.doCommit(ActivateOperation.java:104)
> at
> weblogic
> .deploy
> .internal
> .targetserver.operations.StartOperation.doCommit(StartOperation.java:
> 139)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .operations.AbstractOperation.commit(AbstractOperation.java:320)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .DeploymentManager.handleDeploymentCommit(DeploymentManager.java:816)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .DeploymentManager.activateDeploymentList(DeploymentManager.java:1223)
> at
> weblogic
> .deploy
> .internal
> .targetserver.DeploymentManager.handleCommit(DeploymentManager.java:
> 434)
> at
> weblogic
> .deploy
> .internal
> .targetserver
> .DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:
> 161)
> at
> weblogic
> .deploy
> .service
> .internal
> .targetserver
> .DeploymentReceiverCallbackDeliverer
> .doCommitCallback(DeploymentReceiverCallbackDeliverer.java
> :181)
> at
> weblogic
> .deploy
> .service
> .internal.targetserver.DeploymentReceiverCallbackDeliverer.access
> $100(DeploymentReceiverCallbackDeliverer.java:12)
> at
> weblogic
> .deploy
> .service.internal.targetserver.DeploymentReceiverCallbackDeliverer
> $2.run(DeploymentReceiverCallbackDeliverer.java:67)
> at weblogic.work.SelfTuningWorkManagerImpl
> $WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
> at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
> at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
>
>
> _______________________________________________
> Mark A. Rabick
> Software Engineer
> Northrop Grumman - C2 Systems (MS/C2SD/IIS)
> 3200 Samson Way
> Bellevue, NE 68123
> Ph: (402) 293-7091
> Em: mark.rabick_at_ngc.com
> Remember PFC Ross A. McGinnis...
> http://www.army.mil/medalofhonor/McGinnis/index.html
> ... MA2 Michael A. Monsoor, Lt. Michael P. Murphy, Cpl. Jason
> Dunham, SFC Paul Ray Smith and the rest...
> http://www.cmohs.org/recipients/most_recent.htm
>