Jboss eap升级到7.2使用Jersey的问题

最近升级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.apijavax.ws.rs.api是必须要加的,需要将jboss中的javaeemodule都禁用到,如果只是排除org.jboss.resteasy.resteasy-jaxrs好像并不会完全禁用掉resteasy.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。