最近升級Jboss的時候遇到了一個問題,我們使用jersey提供web服務(wù)的揖膜,然后客戶端也是使用Jersey-Client調(diào)用后臺服務(wù)的誓沸,但是在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報出的問題,而不是我們預(yù)想的使用jersey-client來讀取response壹粟。之前在jboss-eap-6.4中我們?yōu)榱私胷esteasy拜隧,在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.