Reputation: 69
I'm facing an issue on Wildfly 13
when using rest easy to call services as a client.
I deploy many EJB projects inside an ear
. Dependencies are managed by maven except libraries provides by the wildfly 13
application Server (from module folder). I make deployment with the latest version of JBoss Tools.
My app publishes some rest services as a server. When I call those web services (from postman for eg), every thing is fine. The rest API org.jboss.resteasy.resteasy-jaxrs 3.5.1
provided by Wildfly works without issue as expected.
But my app needs also to connect to an external rest web service, this time as a client. I've coded a stateless EJB instantiating a WebTarget targeting the provided URL (that is the target of the external rest service) :
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);
}
}
But when I launched the call, Wildfly can't build the webtarget and resteasy throws the following exception:
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)
I'm aware about incompatibility of versions between resteasy and apache httpcomponents packages provided as modules in former versions of Wildfly. But in Wildfly 13, the org.jboss.resteasy.resteasy-jaxrs
is up to version 3.5.1 and org.apache.httpcomponents
is up to version 4.5.2 for httpclient, 4.4.4 for httpcore, 4.1.3 for for httpasyncclient and 4.5.2 for httpmime.
Does anybody faced the same issue ? Else, does anybody has got an idea about how to solve it ?
Upvotes: 1
Views: 965
Reputation: 69
I finally solved this issue. Actually, module org.apache.httpcomponents is not loaded by default by Wildfly meanwhile the resteasy module has got a dependency with it. So just force the loading of the module into the standalone.xml/domain.xml deployment file as written below :
<subsystem xmlns="urn:jboss:domain:ee:4.0">
<global-modules>
<module name="org.apache.httpcomponents"/>
</global-modules>
...
</subsystem>
Upvotes: 1