Wildfly and jerseys MultiPartFeature.class [英] wildfly and jerseys MultiPartFeature.class
问题描述
我想从tomcat迁移到Wildfly 10.1,所以我创建了一个Web应用程序,用于在Wildfly上测试Jersey rest Web服务.
I want to migrate from tomcat to Wildfly 10.1, so I created a web application for testing Jersey rest web service on Wildfly.
当我运行项目时,它根据 MultiPartFeature.class
when I run the project it shows error according to MultiPartFeature.class
这是我的 ApplicationConfigure.java
@ApplicationPath("api")
public class ApplicationConfigure extends ResourceConfig {
public ApplicationConfigure() {
register(JacksonJaxbJsonProvider.class);
register(JacksonFeature.class);
register(MultiPartFeature.class);
packages(true, "com.example.controllers");
}
}
这是错误(WildFly日志):
and this is the error (WildFly log):
11:18:13,855 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 69) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./wildfly-webapplcation: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./wildfly-webapplcation: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1437)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1368)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1290)
at org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:2438)
at org.jboss.resteasy.spi.ResteasyProviderFactory.register(ResteasyProviderFactory.java:99)
at org.jboss.resteasy.util.FeatureContextDelegate.register(FeatureContextDelegate.java:37)
at org.jboss.resteasy.util.FeatureContextDelegate.register(FeatureContextDelegate.java:12)
at org.glassfish.jersey.media.multipart.MultiPartFeature.configure(MultiPartFeature.java:65)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1739)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1368)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1290)
at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:368)
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
Caused by: java.lang.IllegalArgumentException: RESTEASY003900: Unable to find a public constructor for provider class org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide
at org.jboss.resteasy.spi.ResteasyProviderFactory.createConstructorInjector(ResteasyProviderFactory.java:2255)
at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2244)
at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:806)
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1432)
... 37 more
netbeans日志:
netbeans log:
Deploying /usr/local/wildfly-10.1.0.Final/standalone/deployments/wildfly-webapplcation-1.0.war
"{
\"WFLYCTL0080: Failed services\" => {\"jboss.undertow.deployment.default-server.default-host./wildfly-webapplcation\" => \"org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./wildfly-webapplcation: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
Caused by: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
Caused by: java.lang.IllegalArgumentException: RESTEASY003900: Unable to find a public constructor for provider class org.glassfish.jersey.media.multipart.internal.MultiPartReaderServerSide\"},
\"WFLYCTL0412: Required services that are not installed:\" => [\"jboss.undertow.deployment.default-server.default-host./wildfly-webapplcation\"],
\"WFLYCTL0180: Services with missing/unavailable dependencies\" => undefined
}"
当我删除 MultiPartFeature.class
时,它部署得很好.
when I remove the MultiPartFeature.class
it is deployed pretty well.
顺便说一句,该应用程序可以很好地在 Tomee
上运行.
by the way, this application works on Tomee
nicely.
我该怎么办?我的上传API需要此功能
what should I do? I need this feature for my uploads api
推荐答案
作为应用服务器,Wildfly提供了自己的JAX-RS规范实现.这里使用的框架不是RESTEasy,而是Jersey.
As application server Wildfly provides its own implementation of JAX-RS specification. Here the framework in play is RESTEasy not Jersey.
因此如何从您的日志中看到它:
So how it can be seen from your log:
Caused by: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1437)
RESTEasy引擎正在尝试启动Jersey的功能,但未能成功.在JAX-RS实现中并没有太多的统一,因此很多时候它们是不兼容的.
RESTEasy engine is trying to start Jersey's feature and fail to do so. There is not so much unification in JAX-RS implementations so quite often they are incompatible.
您有两种可能的解决方案
You have two possible solutions
-
从Jersey切换到RESTEasy.多部分支持有些不同
关闭Wildfly对应用程序的RESTEasy扫描,并在内部启动Jersey服务器.互联网上有很多关于它的文章.不确定哪种方法适用于您的版本.
Turn off Wildfly's RESTEasy scanning of your application and start Jersey server internally. There are multiple articles on the internet about it. Not sure which approach will work for your version.
这篇关于Wildfly and jerseys MultiPartFeature.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!