Question

I am working on a JAX-RS application. Before, I had it as a WAR mounted on a Tomcat server and I was obtaining the HTTTP Request Method using: javax.servlet.http.HttpServletRequest.getMethod().

However, now I'm working with an embedded Grizzly server on my application and have found the following error on startup:

Missing dependency for constructor public wci.api.resource.AudioSessionResource(javax.servlet.http.HttpServletRequest) at parameter index 0

All my resources extends a MyHappyCustomResource class that has a constructor which receives an HttpServletRequest, provided by the resource constructor via Injection.

This is an example of a resource constructor, the super call is from MyHappyCustomResource:

import javax.servlet.http.HttpServletRequest;

public AudioSessionResource(@Context HttpServletRequest request) {
    super(request);
    this.dao = new AudioSessionDao(this.sessionManager.getCurrentSession());
}

Right now I need this just to get the HTTP-Method so, any other or more correct way to do it it's appreciated.

Was it helpful?

Solution

The solution was to use Grizzly's Request class as told by this page on the Grizzly official site:

https://grizzly.java.net/httpserverframework.html

Similar abstractions to those offered by the Servlet specification: HttpHandler (Servlet), Request (HttpServletRequest), Response (HttpServletResponse).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top