[JERSEY-550] Excessively vague exception when jersey-json is missing Created: 21/Jun/10 Updated: 10/Sep/15 Resolved: 26/Aug/10 Status: Project: Component/s: Affects Version/s: Fix Version/s: Closed jersey core 1.1.5 Type: Reporter: Resolution: Labels: Remaining Estimate: Time Spent: Original Estimate: Environment: Bug minfrin Fixed None Not Specified Issuezilla Id: 550 1.4 Priority: Assignee: Votes: Major jersey-issues 0 Not Specified Not Specified Operating System: All Platform: Macintosh Description When a method is configured to return json content generated from JAXB, but jersey-json jars are not present, the jersey container returns the following meaningless WebApplicationException with no detail string as below. What jersey should do at this point is construct a proper error string, with a detailed explanation of exactly what the error is, and send it to the client, so the end user's time is not wasted. HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 Content-Type: text/plain Transfer-Encoding: chunked Date: Mon, 21 Jun 2010 23:38:27 GMT Connection: close javax.ws.rs.WebApplicationException at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:268) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932) at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:637) Comments Comment by minfrin [ 21/Jun/10 ] Update the version affected. Comment by sandoz [ 22/Jun/10 ] Did you see a severe message in the log of the form: A message body writer for Java class <foo>, and Java type <foo>, and MIME media type application/json was not found. ? we currently do not include that message in the exception and i think we should. Jersey deliberately does not send anything to the client because if it sends a response entity then there is no possibility for the application to customize e.g. with a error page mapper. I think what we should do is support the sending of the exception stack trace as a response header when tracing is enabled, or send a URL to where the stack trace can be obtained from. That way when in "debug" mode there is information available. Comment by minfrin [ 22/Jun/10 ] Alas, nothing further was logged. This was being run from tomcat from within eclipse, so all logging was being sent to the error console within eclipse. Nothing showed up there. Comment by sandoz [ 22/Jun/10 ] That is odd. Here is the code for Jersey 1.1.5.1 which is the same for 1.1.5: http://fisheye4.atlassian.com/browse/jersey/tags/jersey-1.1.5.1/jersey/jerseyserver/src/main/java/com/sun/jersey/spi/container/ContainerResponse.java?r=HEAD#l268 Notice the following at line 259: Â Â Â Â Â Â Â Â Â Â Â LOGGER.severe("A message body writer for Java type, " + entity.getClass() + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ", and MIME media type, " + contentType + ", was not found"); Comment by sandoz [ 26/Aug/10 ] Fixed in the trunk. I added a message to the exception for both reading and writing. Note that i still think there is something up with the JDK logging in the environment you are using. Generated at Sun Mar 06 04:52:12 UTC 2016 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.