문제

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.

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top