Search code examples
javajakarta-eeerror-logginggrizzly

grizzly does not log Exceptions in requests


I've set up a simple jersey server like this:

ResourceConfig rc = new ResourceConfig().packages("com.example.jersey_test/services");
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(API_URI), rc);

And I have a bean that simply throws an exception:

@Path("persons")
public class PersonService {
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String getPersons() {
        java.util.logging.Logger.getGlobal().log(Level.INFO, "test");
        throw new RuntimeException("test");
    }
}

The log output is the following (so logging works, but the exception is not logged):

Jul 01, 2014 10:19:33 PM com.example.jersey_test.services.PersonService getPersons
INFO: test

The response is a 500 with looks like the following (so the stacktrace is not included):

grizzly 500 error

As this answer states, grizzly should be using the default logging API. What am I doing wrong?


Solution

  • There is a way to start a grizzly server that both logs and prints out exceptions in the response:

    HttpServer server =
        GrizzlyWebContainerFactory.create(getBaseURI(),
        Collections.singletonMap("javax.ws.rs.Application",
        "class.that.extends.ResourceConfig"));