严重:找不到媒体类型= application / atom + xml,type = class com.rometools.rome.feed.atom.Feed等的MessageBodyWriter

时间:2016-09-30 08:06:06

标签: rest jersey

错误:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/atom+xml, type=class com.rometools.rome.feed.atom.Feed, genericType=class com.rometools.rome.feed.atom.Feed. 

的pom.xml

我的pom.xml文件已包含多部分依赖项

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>

的web.xml 我在下面新添加了在web.xml中注册multipart功能

<servlet>
<servlet-name>rest-api</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.myCom.myloader.resource</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.media.multipart.MultiPartFeature
</param-value>
</init-param>
</servlet>

客户端类 我的客户端代码如下所示

Client client =    ClientBuilder.newBuilder().register(MultiPartFeature.class).build()
MultiPart multipart = new FormDataMultiPart();
multipart.bodyPart(new FileDataBodyPart(transactionId + ".nq.gz", nquadsFile, javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM_TYPE));

WebTarget resource = client.target(this.rdfServerUrl + "/content/" + action);

Feed rdfLoaderClientResponse = resource.request()
   .accept(MediaType.APPLICATION_ATOM_XML_TYPE)
   .header("x-batchid-X-batch", transactionId)
   .post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE), Feed.class);

Apache Server Catalina.out日志

Apache Tomcat Rest服务器错误:

Sep 29, 2016 1:36:05 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 5 * Server has received a request on thread http-8080-1
5 > POST http://www.example.com:8080/myloader/api/virtuosoCluster/content/update
5 > accept: application/atom+xml
5 > connection: keep-alive
5 > content-length: 76681
5 > content-type: multipart/form-data;boundary=Boundary_25_1353837368_1475156166272
5 > host: www.example-client.com:8080
5 > mime-version: 1.0
5 > user-agent: Jersey/2.22.2 (HttpUrlConnection 1.7.0_111)
5 > x-batchid-X-batch: xxxxxxx

Sep 29, 2016 1:36:05 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 5 * Server responded with a response on thread http-8080-1
5 < 200
5 < Content-Type: application/atom+xml

Sep 29, 2016 1:36:05 PM org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
SEVERE: MessageBodyWriter not found for media type=application/atom+xml, type=class com.rometools.rome.feed.atom.Feed, genericType=class com.rometools.rome.feed.atom.Feed.
Sep 29, 2016 1:36:05 PM org.glassfish.jersey.filter.LoggingFilter log
INFO: 5 * Server responded with a response on thread http-8080-1
5 < 500

客户端错误:

javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
at     org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:1020)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:816)
at org.glassfish.jersey.client.JerseyInvocation.access$700(JerseyInvocation.java:92)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:700)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:444)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:696)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:448)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:349)

0 个答案:

没有答案