wildfly和球衣MultiPartFeature.class

问题描述 投票:0回答:2

我想从Tomcat迁移到Wildfly 10.1,所以我创建了上Wildfly测试泽西REST Web服务的Web应用程序。

当我运行该项目就说明根据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日志):

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的日志:

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它部署相当不错。

顺便说一下,这个应用程序适用于Tomee很好。

我该怎么办?我需要这个功能对我的上传API

java jersey-2.0 wildfly-10
2个回答
4
投票

作为应用服务器Wildfly提供它自己的实现JAX-RS规范。在这里,在剧中框架的RESTEasy不球衣。

因此,如何能够从你的日志中可以看出:

Caused by: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1437)

的RESTEasy引擎正在试图启动新泽西州的功能,并没有这样做。有没有这么多统一的JAX-RS实现所以他们往往是不兼容的。

有两种可能的解决方案

  1. 切换从泽西岛的RESTEasy。有multipart support有些不同
  2. 关闭应用程序的Wildfly的的RESTEasy扫描和内部启动泽西服务器。有关于它在互联网上的多篇文章。不知道哪种方法会为你的版本。

0
投票

我通过这个问题了when,我设法通过手动调用JerseyClientBuilder().build()而不是ClientBuilder().build()强制使用的球衣我的应用程序。

Jersey客户端似乎是默认的,所以如果你有另外一个定义这将是一个由ClientBuilder().build()采摘。

© www.soinside.com 2019 - 2024. All rights reserved.