在使用Wildfly 13
作为客户使用轻松易用的呼叫服务时,我遇到了一个问题。
我在ear
内部署了许多EJB项目。依赖关系由maven管理,除了wildfly 13
应用程序服务器提供的库(来自模块文件夹)之外。我使用最新版本的JBoss Tools进行部署。
我的应用程序将一些其他服务发布为服务器。当我调用这些Web服务(例如从邮递员那里)时,一切都很好。 Wildfly提供的其余API org.jboss.resteasy.resteasy-jaxrs 3.5.1
可以正常工作。
但是我的应用程序还需要连接到外部Rest Web服务,这次是作为客户端。我已经编写了一个无状态EJB实例化了一个WebTarget,该WebTarget面向提供的URL(这是外部rest服务的目标):
protected void setTarget(URL target) throws FmRestApiException {
try {
String sUrl = target.toString();
this.target = ClientBuilder.newClient().target(sUrl);
}
catch(Exception e) {
throw new FmRestApiException("Can't initialize FM Rest API to target "+target,e);
}
}
但是当我发起呼叫时,Wildfly无法构建webtarget,resteasy引发以下异常:
Caused by: java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingClientConnectionManager
at org.jboss.resteasy.client.jaxrs.ClientHttpEngineBuilder4.build(ClientHttpEngineBuilder4.java:110)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.buildOld(ResteasyClientBuilder.java:381)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:390)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:38)
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
at com.novarem.commons.fmapi.rest.AbstractFmApiRestClient.setTarget(AbstractFmApiRestClient.java:37)
at fr.remmedia.fmadapter.FmRestApiGateway.init(FmRestApiGateway.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:122)
at org.jboss.as.weld.interceptors.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:111)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:509)
at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:72)
at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:89)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:112)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.weld.interceptors.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:105)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:237)
... 270 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.conn.PoolingClientConnectionManager from [Module "org.jboss.resteasy.resteasy-jaxrs" version 3.5.1.Final from local module loader @4c40b76e (finder: local module finder @2ea6137 (roots: /Library/JBoss/wildfly-remmedia-13/modules,/Library/JBoss/wildfly-remmedia-13/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
我知道在Restwild和以前的Wildfly版本中作为模块提供的resteasy和apache httpcomponents软件包之间的版本不兼容。但是在Wildfly 13中,org.jboss.resteasy.resteasy-jaxrs
的最高版本为3.5.1,而org.apache.httpcomponents
的最高版本是httpclient 4.5.2,httpcore 4.4.4,httpasyncclient 4.1.3和4.5.2。用于httpmime。
有人遇到同样的问题吗?否则,有人知道如何解决吗?
答案 0 :(得分:0)
我终于解决了这个问题。实际上,Wildfly默认不加载模块org.apache.httpcomponents,而resteasy模块具有依赖关系。因此,只需按以下说明强制将模块加载到standalone.xml / domain.xml部署文件中:
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<global-modules>
<module name="org.apache.httpcomponents"/>
</global-modules>
...
</subsystem>