我有一个RestEasy客户端,我想在部署到Tomee的REST服务中使用。一切都很好,但在部署时我得到错误
fable-service> java.lang.IllegalArgumentException: class org.jboss.resteasy.plugins.providers.FormUrlEncodedProvider is not a SERVER provider
fable-service> at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.isNotServerProvider(CxfRsHttpListener.java:491)
fable-service> at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.providers(CxfRsHttpListener.java:434)
fable-service> at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.configureFactory(CxfRsHttpListener.java:1009)
fable-service> at org.apache.openejb.server.cxf.rs.CxfRsHttpListener.deployApplication(CxfRsHttpListener.java:577)
fable-service> at org.apache.openejb.server.rest.RESTService.deployApplication(RESTService.java:481)
fable-service> at org.apache.openejb.server.rest.RESTService.afterApplicationCreated(RESTService.java:288)
fable-service> at org.apache.tomee.webservices.TomeeJaxRsService.afterApplicationCreated(TomeeJaxRsService.java:53)
fable-service> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
fable-service> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
fable-service> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
fable-service> at java.lang.reflect.Method.invoke(Method.java:498)
fable-service> at org.apache.openejb.observer.ObserverManager$MethodInvocation.invoke(ObserverManager.java:406)
fable-service> at org.apache.openejb.observer.ObserverManager$InvocationList.invoke(ObserverManager.java:521)
fable-service> at org.apache.openejb.observer.ObserverManager.doFire(ObserverManager.java:111)
fable-service> at org.apache.openejb.observer.ObserverManager.fireEvent(ObserverManager.java:100)
fable-service> at org.apache.openejb.loader.SystemInstance.fireEvent(SystemInstance.java:134)
fable-service> at org.apache.tomee.catalina.TomcatWebAppBuilder.afterStart(TomcatWebAppBuilder.java:1746)
fable-service> at org.apache.tomee.catalina.GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:116)
fable-service> at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
fable-service> at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:395)
fable-service> at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
fable-service> at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
fable-service> at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
fable-service> at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
fable-service> at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:988)
fable-service> at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1860)
fable-service> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
fable-service> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
fable-service> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
fable-service> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
fable-service> at java.lang.Thread.run(Thread.java:748)
我尝试过使用不同版本的RestEasy和Tomee,但错误并没有改变。目前我在tomee中使用RestEasy 3.5.1.Final:8-jre-7.0.4-plus Docker容器。
不幸的是,谷歌并没有帮助我解决这个问题......
答案 0 :(得分:0)
我也刚开始工作。带有RestEasy的TomEE Plus 7.1.0
这是需要做的:
为避免出现“不是SERVER提供程序”异常,需要将系统属性“ openejb.jaxrs.fail-on-constrainedto”设置为false。此功能来自CxfRsHttpListener类。
TomEE Plus 7.1.0使用Java 8,但是在“ lib”文件夹中有一个名为“ javaee-api-7.0-1.jar”的jar。 TomEE启动时,无论您在maven或gradle中配置为项目依赖项,它都会使用该文件夹中的所有jar。而且,您将获得JavaEE 7类的机会很大。
RestEasy 3.5.1.Final是JAX-RS-API 2.1规范的实现。因此,使用JavaEE7,您将在MediaType中获得异常NoSuchFieldError SERVER_SENT_EVENTS_TYPE。
为避免这种情况,您需要使用Resteasy 3.1.4.Final,它是JAX-RS-API 2.0.1规范的实现