I want to create a simple REST service, and for that I am using Jersey and Grizzly.
Here is my Service class:
@Path("/service")
class TestRESTService {
@GET
@Path("test")
@Produces(Array(MediaType.APPLICATION_JSON))
public String test() {
return "{ \"TestField\" : \"TestValue\" }";
}
}
And from what I understand here is how I supposed to start it:
ResourceConfig config = new ResourceConfig();
config.registerClasses(TestRESTService.class);
URI serverUri = UriBuilder.fromUri("http://localhost/").port(19748).build();
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(serverUri, config);
server.start();
But it's not working. :( I tried to send a request to
http://localhost:19748/service/test
using Google Chrome's Postman plugin by adding 'Accept' : 'application/json' as a Http Header, but nothing is returned. The 'hourglass' is just spinning around.
Could you please help me?
This one works for me: