我正在使用Jersey服务来调用服务,我得到了这个例外。任何帮助赞赏。这个问题是间歇性的。
[|SEVERE|oracle-glassfish3.1.2|com.sun.jersey.api.client.ClientResponse|_ThreadID=99;_ThreadName=quartzScheduler_Worker-5;|A message body reader for Java class com.xxx.ResonseObjectView, and Java type class com.xxx.ResonseObjectView, and MIME media type text/html; charset=utf-8 was not found|#]
[|SEVERE|oracle-glassfish3.1.2|com.sun.jersey.api.client.ClientResponse|_ThreadID=99;_ThreadName=quartzScheduler_Worker-5;|The registered message body readers compatible with the MIME media type are:
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
com.sun.jersey.core.impl.provider.entity.EntityHolderReader
com.sun.jersey.moxy.MoxyMessageBodyWorker
com.sun.jersey.moxy.MoxyListMessageBodyWorker
|#]
将@XmlRootElement用于响应POJO
@XmlRootElement
public class ResponseObjectView extends BaseRestObject
@XmlRootElement
public class BaseRestObject
这就是调用服务的方式
protected ClientResponse executeRequest( String resourceUrl, Object argument )
{
if( argument instanceof SecureToken )
{
SecureToken parameter = (SecureToken) argument ;
parameter.setSecurityToken( MD5Hash.hash( parameter.getHashableAttribute(), salt ) );
}
return this.buildWebResource( resourceUrl ).type( MediaType.APPLICATION_JSON_TYPE ).accept( MediaType.APPLICATION_JSON_TYPE ).post( ClientResponse.class, argument );
}
这是使用和生成MediaType JSON
的服务
@POST
@Path( "/test.biws" )
@Consumes( MediaType.APPLICATION_JSON )
@Produces( { MediaType.APPLICATION_JSON } )
public ResponseObjectView request( RequestObjectView request, @Context UriInfo uriInfo )
{
................
return response;
}