users@jersey.java.net

Re: [Jersey] [JSON]JAXBContextResolver met with VerifyError in JBoss-4.x-jdk6

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 11 May 2009 14:11:37 +0200

On May 11, 2009, at 1:54 PM, Chris Winters wrote:

> I think you need to use JAXB 2.1.10, and if you use JDK 6 you need
> to put the relevant JARs in an 'endorsed' directory.
>
Correct.

Paul.
> Chris
>
>
> On May 11, 2009 4:26 AM, "William" <zhou_william_at_yahoo.cn> wrote:
>
>
> Hi,
>
> When I upgraded the deployment of my Jersey application from JBOSS
> 4.2.3.GA (env:JDK5) to JBOSS 4.2.3.GA-jdk6 (env:JDK6), I met an
> error. The issue was in JAXBContextResolver, my class is:
>
> @Provider
> public class JAXBContextResolver implements
> ContextResolver<JAXBContext> {
> public JAXBContextResolver() throws Exception {
> this.m_context = new
> JSONJAXBContext(JSONConfiguration.natural().build(), m_types);
> }
>
> public JAXBContext getContext(Class<?> objectType) {
> return (m_types[0].equals(objectType)) ? m_context : null;
> }
>
> private JAXBContext m_context;
> private final Class[] m_types = {my.example.Representation.class};
> }
>
> 1) I have configured my application.xml, including the providers;
> 2) I used different JDK env for different versions of JBoss.
>
> Error message in JBoss console was:
>
> INFO: Scanning for root resource and provider classes in the packages:
> my.example.resource
> my.example.provider
> my.example.provider.exception
> 02:33:21,297 ERROR [STDERR] May 11, 2009 2:33:21 AM
> com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Root resource classes found:
> class my.example.resource.ServiceResource
> 02:33:21,297 ERROR [STDERR] May 11, 2009 2:33:21 AM
> com.sun.jersey.api.core.PackagesResourceConfig init
> INFO: Provider classes found:
> class my.example.provider.JAXBContextResolver
> class my.example.provider.JAXBMarshallerResolver
> class my.example.provider.ContentStreamingOutputProvider
> class my.example.provider.DomDocumentWriterProvider
> class my.example.provider.exception.DefaultExceptionMapper
> 02:33:21,407 ERROR [[/resources]] StandardWrapper.Throwable
> java.lang.VerifyError: (class: my/example/provider/
> JAXBContextResolver, method: <init> signature: ()V)
> Bad type in putfield/putstatic
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
> at java.lang.Class.privateGetPublicMethods(Unknown Source)
> at java.lang.Class.getMethods(Unknown Source)
> at
> com.sun.jersey.core.reflection.MethodList.<init>(MethodList.java:57)
> at
> com
> .sun
> .jersey
> .core
> .spi
> .component
> .ComponentConstructor
> .getPostConstructMethod(ComponentConstructor.java:124)
> at
> com
> .sun
> .jersey
> .core
> .spi.component.ComponentConstructor.<init>(ComponentConstructor.java:
> 118)
> at
> com
> .sun
> .jersey
> .core.spi.component.ProviderFactory.getInstance(ProviderFactory.java:
> 205)
> 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
> org
> .apache
> .catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
> at
> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:
> 981)
> at
> org
> .apache
> .catalina.core.StandardContext.loadOnStartup(StandardContext.java:
> 4071)
> at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:
> 4375)
> at
> org
> .apache
> .catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
> at
> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
> 770)
> at
> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org
> .apache
> .tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
> at
> org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:
> 164)
> at
> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
> at
> org.apache.catalina.core.StandardContext.init(StandardContext.java:
> 5312)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org
> .apache
> .tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:296)
> at
> org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:
> 164)
> at
> org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
> at org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal
> (TomcatDeployer.java:301)
> at
> org
> .jboss
> .web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java:
> 104)
> at
> org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:375)
> at org.jboss.web.WebModule.startModule(WebModule.java:83)
> at org.jboss.web.WebModule.startService(WebModule.java:61)
> at
> org
> .jboss
> .system
> .ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
> at
> org
> .jboss
> .system
> .ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:
> 245)
> at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
>
> I found the error occured in the line:
> this.m_context = new JSONJAXBContext(...);
>
> In the meanwhile, I made some tests,
> 1) No error when deploying my app in JBoss 4.2.3.GA (JDK5).
> 2) If I change the generic return type of getContext() to
> JSONJAXBContext, no error as well.
>
> Does anyone have ideas?
>
>
>
>
> ___________________________________________________________
> 好玩贺卡等你发,邮箱贺卡全新上线!
> http://card.mail.cn.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>