最近升级Jboss的时候遇到了一个问题,我们使用jersey提供web服务的,然后客户端也是使用Jersey-Client调用后台服务的,但是在jboss从6.4 升级到7.2 之后遇到了一个错误:
Caused by: com.oocl.csc.frm.soa.proxy.exception.FWProxyException: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type text/html;charset=UTF-8 and type class java.lang.String
at com.oocl.csc.frm.soa.proxy.util.FWProxyUtil.handleException(FWProxyUtil.java:205)
at com.oocl.csc.frm.soa.proxy.rest.FWRESTServiceProxy.getAll(FWRESTServiceProxy.java:885)
at com.oocl.ir4.sps.web.service.integrator.TMSCustomerContractServiceImpl.get(TMSCustomerContractServiceImpl.java:44)
at com.oocl.ir4.sps.web.controller.integrator.IntegratorController.getTMSCustomerContractInfo(IntegratorController.java:443)
... 96 more
Caused by: javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type text/html;charset=UTF-8 and type class java.lang.String
at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:42)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:334)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:261)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:237)
at com.oocl.csc.frm.soa.proxy.rest.FWRESTServiceProxy.getAll(FWRESTServiceProxy.java:874)
从错误信息中可以看到这是从resteasy报出的问题,而不是我们预想的使用jersey-client来读取response。之前在jboss-eap-6.4中我们为了禁用resteasy,在web.xml添加了这些config:
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>false</param-value>
</context-param>
看起来这些配置没有将所有的resteasy模块都禁用掉,客户端还是使用了Resteasy,后来查了一下文档,如果想在jboss-eap-7中完全禁用resteasy需要在jboss-deployment-structure.xml
中添加一下配置:
<exclusions>
<module name="javaee.api" />
<module name="javax.ws.rs.api"/>
<module name="org.jboss.resteasy.resteasy-jaxrs" />
</exclusions>
其中前面两个modulejavaee.api
和javax.ws.rs.api
是必须要加的,需要将jboss中的javaeemodule都禁用到,如果只是排除org.jboss.resteasy.resteasy-jaxrs
好像并不会完全禁用掉resteasy.