gpt4 book ai didi

java - 使用 proguard 进行混淆后出现 Jersey 错误,尝试实例化抽象类

转载 作者:行者123 更新时间:2023-12-01 04:41:55 28 4
gpt4 key购买 nike

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

当我部署未混淆的项目时,它工作正常。然而,当我混淆时,即使我告诉 ProGuard 不要混淆 GsonMessageBodyHandlerJsonMessageBodyHandler , Jersey 由于某种原因坚持尝试实例化 GsonMessageBodyHandler作为一个提供者,然后因为它是抽象的而失败。我无法弄清楚是什么导致 Jersey 尝试加载这个抽象类,但前提是混淆了。有人可以帮忙吗?

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]

最佳答案

也许您还没有保留注释:

-keepattributes *Annotation*

关于java - 使用 proguard 进行混淆后出现 Jersey 错误,尝试实例化抽象类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16389437/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com