簡體   English   中英

MediaType.APPLICATION_JSON和MediaType.APPLICATION_XML異常,但MediaType.TEXT_XML運行正常

[英]Exception with MediaType.APPLICATION_JSON and MediaType.APPLICATION_XML but MediaType.TEXT_XML running fine

Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error獲取異常作為Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error

當我使用Jersey + JaxB但以相同的Web服務運行“基於Java應用程序”的Web服務運行Rest Based客戶端時,在我的Rest Based Web服務中的@Produces({MediaType.APPLICATION_JSON})或@Produces({MediaType.APPLICATION_XML}}當我使用@Produces({MediaType.TEXT_XML})時。

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

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

//下面的輸出用於MediaType.TEXT_XML這是我的第一個任務這是我的第一個任務

//下面的輸出用於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)

genson.jar添加到您的類路徑中,這將為Json提供支持。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM