Exception with MediaType.APPLICATION_JSON and MediaType.APPLICATION_XML but MediaType.TEXT_XML running fine

1.2k views Asked by At

Getting exception as Exception in thread "main" javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error.

For @Produces({MediaType.APPLICATION_JSON }) or @Produces({MediaType.APPLICATION_XML }) in my Rest Based webservice when I run Rest Based client as "Run as Java Application" webservice using Jersey + JaxB BUT same web service giving expected output when I am using @Produces({ MediaType.TEXT_XML }).

Note: I am using Rest Based + Jersy +JaxB, I have done annotation at POJO side too as "@XmlRootElement".

Below is console logs::::

// Below output is for MediaType.TEXT_XML This is my first todoThis is my first todo

// Below output is for 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

There are 1 answers

0
SaTya On

Add genson.jar to your classpath.This will provide support for Json.