MediaType.APPLICATION_JSON和MediaType.APPLICATION_XML但MediaType.TEXT_XML运行正常的例外情况

时间:2014-11-20 05:29:49

标签: java media-type

将例外情况设为Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error

对于我的Rest Based webservice中的@Produces({MediaType.APPLICATION_JSON})或@Produces({MediaType.APPLICATION_XML}) 当我运行Rest Based客户端作为“作为Java应用程序运行”时 使用Jersey + JaxB的webservice但是当我使用@Produces({MediaType.TEXT_XML})时,同样的Web服务会给出预期的输出。

注意:我使用的是Rest Based + Jersy + JaxB,我在POJO方面也做了注释“@XmlRootElement”。

以下是控制台日志::::

//输出下方是MediaType.TEXT_XML 这是我的第一次todo这是我的第一次todo

//输出下方是MediaType.APPLICATION_JSON

Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:968)
at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:795)
at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)
at org.glassfish.jersey.client.JerseyInvocation$2.call(JerseyInvocation.java:683)
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:424)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:679)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:408)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:308)
at com.restfull.demo2.Test.main(Test.java:32)

1 个答案:

答案 0 :(得分:-1)

genson.jar添加到您的类路径中。这将为Json提供支持。

相关问题