Alex Shtuk Alex Shtuk - 1 year ago 103
Java Question

JAX-RS with Jersey & Grizzly: 500 Request failed for all requests


I need to develop simple web service on java.
I'm new to java tech and based on several articles decided to use JAX-RS (Jersey) with embedded http server (Grizzly2), because it looks suitable for building REST services and deployment seems to be trivial.

In my dev environment all works perfect (using IntllijIdea).

But when I try to deploy on test server every request returns "500 Internal Error" (even /application.wadl)

Here more info:

Simple resource

public class SpeechRecognition {
public Response test() {
Logger.getGlobal().log(Level.INFO, "resource test");
return Response.ok("success", MediaType.TEXT_PLAIN).build();

Simple resource config

public class SimpleApiServer extends ResourceConfig {
public SimpleApiServer() {

property(ServerProperties.TRACING, "ALL");
property(ServerProperties.TRACING_THRESHOLD, "VERBOSE");


Simple app start

public static void main(String[] args) throws IOException {
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer("", new SimpleApiServer());

System.out.println(String.format("Jersey app started with WADL available at "
+ "%sapplication.wadl\nHit enter to stop it...", serverUri.toString()));;

Exception mapping

public class AppExceptionMapper implements ExceptionMapper<Throwable> {
public Response toResponse(Throwable ex) {
Logger.getGlobal().log(Level.WARNING, "exception response");


return Response.status(500).entity(Exceptions.getStackTraceAsString(ex)).type("text/plain")

What is happening

For every request I see in console

- that grizzly accepts it (prints all information about headers etc.)
- and that resource code is executed ("resource test" is printed)

And nothing more.

In postman I receive "500 Request Failed" with no trace from Jersey in headers (though I specified property(ServerProperties.TRACING, "ALL");)

No information printed in server console about any exceptions.

I have an idea, that something bad happens when jersey tries to pass response to grizzly.

Does anyone has any thoughts about where should I look to troubleshoot this problem? I really stuck with it.

And I really don't want to rewrite everything (not this simple ill example, but lots more) to traditional java servlet-oriented code ('cause it's another piece of tech to learn about)


Test server - is the docker container on azure linux VM. Requests are proxied by nginx to exposed docker port. Got web-site on Rails using the same scheme, which works fine.

When grizzly prints info about request it prints incorrect hostname. I.e. actual host name is and grizzly writes GET http://test.api:80/resource

Answer Source

It was the Jersey version mismatch in dev and test environments.

Remote debugging (with IntellijIdea) showed, that in process of forming response

Exception: AbstractMethodError:$StatusType;

is thrown, wich led me to this post.
After fixing the dependencies all works fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download