1

该类GsonMessageBodyHandler是一个实现的抽象类,MessageBodyReader<T>它没有注释。然后,这个方法被一个名为 的类子类化JsonMessageBodyHandlerJsonMessageBodyHandler@Producer和注释@Consumes(MediaType.APPLICATION_JSON)

当我未混淆地部署我的项目时,它工作正常。然而,当我混淆时,即使我告诉 ProGuard 不要混淆GsonMessageBodyHandlerand JsonMessageBodyHandler,Jersey 出于某种原因坚持尝试将其实例GsonMessageBodyHandler化为提供程序,然后因为它是抽象的而失败。我无法弄清楚是什么导致 Jersey 尝试加载这个抽象类,但只有在被混淆的情况下。任何人都可以帮忙吗?

泽西版本是 1.17。

启动日志的相关部分如下:

2013-05-05 01:08:29.363 [localhost-startStop-1] ERROR c.s.j.c.s.component.ProviderFactory - The provider class, class com.rest.common.GsonMessageBodyHandler, could not be instantiated. Processing will continue but the class will not be utilized

java.lang.InstantiationException: null

    at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30) ~[na:1.6.0_35]

    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_35]

    at java.lang.Class.newInstance0(Class.java:355) ~[na:1.6.0_35]

    at java.lang.Class.newInstance(Class.java:308) ~[na:1.6.0_35]

    at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:192) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:179) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ProviderFactory._getComponentProvider(ProviderFactory.java:159) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:153) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:251) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.component.ProviderServices.getProviders(ProviderServices.java:148) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:206) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:163) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1310) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:168) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:774) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:770) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193) [jersey-core-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765) [jersey-server-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489) [jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) [jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) [jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) [jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) [jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) [jersey-servlet-1.17.jar:1.17]

    at javax.servlet.GenericServlet.init(GenericServlet.java:160) [servlet-api.jar:3.0.FR]

    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) [catalina.jar:7.0.32]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:655) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1628) [catalina.jar:7.0.32]

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_35]

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_35]

    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]

    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]



SEVERE: The class com.rest.common.GsonMessageBodyHandler is an abstract class and cannot be instantiated.

2013-05-05 01:08:29.675 [localhost-startStop-1] ERROR o.a.c.c.C.[.[localhost].[/rest] - StandardWrapper.Throwable com.sun.jersey.spi.inject.Errors$ErrorMessagesException: null

    at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765) ~[jersey-server-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) ~[jersey-servlet-1.17.jar:1.17]

    at javax.servlet.GenericServlet.init(GenericServlet.java:160) ~[servlet-api.jar:3.0.FR]

    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) [catalina.jar:7.0.32]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:655) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1628) [catalina.jar:7.0.32]

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_35]

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_35]

    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]

    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]

2013-05-05 01:08:29.691 [localhost-startStop-1] ERROR o.a.c.c.C.[.[localhost].[/rest] - Servlet /rest threw load() exception

com.sun.jersey.spi.inject.Errors$ErrorMessagesException: null

    at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199) ~[jersey-core-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:770) ~[jersey-server-1.17.jar:1.17]

    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:765) ~[jersey-server-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:489) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:319) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374) ~[jersey-servlet-1.17.jar:1.17]

    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557) ~[jersey-servlet-1.17.jar:1.17]

    at javax.servlet.GenericServlet.init(GenericServlet.java:160) ~[servlet-api.jar:3.0.FR]

    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266) ~[catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185) ~[catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080) ~[catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) [catalina.jar:7.0.32]

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) [catalina.jar:7.0.32]

    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) [catalina.jar:7.0.32]

    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:655) [catalina.jar:7.0.32]

    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1628) [catalina.jar:7.0.32]

    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) [na:1.6.0_35]

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) [na:1.6.0_35]

    at java.util.concurrent.FutureTask.run(FutureTask.java:138) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [na:1.6.0_35]

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [na:1.6.0_35]

    at java.lang.Thread.run(Thread.java:662) [na:1.6.0_35]
4

1 回答 1

0

也许您还没有保留注释:

-keepattributes *Annotation*
于 2013-05-09T07:06:43.257 回答