I am building a Jersey Moxy service using the quickstart artifact at the end. My code works fine and I can return JSON. However, when I develop, if I am mistaken, say, the request handler is of an unsupported type, I will get an empty response of 500, which makes debugging difficult. For example, if I incorrectly decorate an attribute with @XmlElementRef, I get a response like:
$ curl -i http://localhost:8080/myapp/test HTTP/1.1 500 Internal Server Error Date: Thu, 05 Sep 2013 10:27:55 GMT Connection: close Content-Length: 0
The server will act as if nothing is happening:
Sep 5, 2013 11:27:46 AM org.glassfish.grizzly.http.server.HttpServer start INFO: [HttpServer] Started. Jersey app started with WADL available at http://localhost:8080/application.wadl Hit enter to stop it...
I tried using the log configuration file with:
-Djava.util.logging.config.file=log.conf
This gives a lot of output, but still does not show any exception.
I tried to view the Grizzly configuration, but I cannot find a way to disable graceful error handling. Ideally, I would like the server to throw an exception. Any suggestions on what I am missing?
Here is my main code:
import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.moxy.json.MoxyJsonConfig; import org.glassfish.jersey.server.ResourceConfig; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; import java.io.IOException; import java.net.URI; import java.util.*; public class Main {
The code is almost identical to the example given here:
https://github.com/jersey/jersey/tree/2.2/examples/json-moxy/src/main/java/org/glassfish/jersey/examples/jsonmoxy
The full archetype generation I used:
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-grizzly2 \ -DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \ -DgroupId=com.myapp -DartifactId=yarese-service -Dpackage=com.myapp \ -DarchetypeVersion=2.2
Suggestions are gratefully received.