Mantis - Resin
Viewing Issue Advanced Details
3111 major always 12-01-08 22:02 08-13-09 17:52
tempestse  
ferg  
normal  
closed 3.1.7  
fixed  
none    
none 4.0.2  
0003111: RequestWrapper throws NPE
A call to getSession() results in a NPE thrown from com.caucho.server.connection.RequestWrapper.isSecure

This issue has already been reported as 0002883 but was closed based on an assumption that the NPE was caused by application error. I am able to reproduce by simply submitting a request that should return a 404. As the Request is torn down, RequestWrapper is invoked and triggers the NPE.

Identical requests running on Jetty and running on Tomcat are handled without any error. At a minimum, I need this patched to throw a meaningful non-runtime Exception. Ideally, Resin would exhibit the same expected behavior as Tomcat and Jetty. My trace is pasted below:
java.lang.NullPointerException
    at com.caucho.server.connection.RequestWrapper.isSecure(RequestWrapper.java:296)
    at com.caucho.server.connection.RequestAdapter.getCookieName(RequestAdapter.java:463)
    at com.caucho.server.connection.RequestAdapter.getSession(RequestAdapter.java:387)
    at com.caucho.server.webapp.DispatchRequest.getSession(DispatchRequest.java:448)
    at org.springframework.web.context.request.ServletRequestAttributes.getSession(ServletRequestAttributes.java:87)
    at org.springframework.web.context.request.ServletRequestAttributes.updateAccessedSessionAttributes(ServletRequestAttributes.java:221)
    at org.springframework.web.context.request.AbstractRequestAttributes.requestCompleted(AbstractRequestAttributes.java:47)
    at org.springframework.web.context.request.RequestContextListener.requestDestroyed(RequestContextListener.java:87)
    at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:102)
    at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:192)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
    at com.caucho.server.webapp.RequestDispatcherImpl.include(RequestDispatcherImpl.java:494)
    at com.caucho.server.webapp.RequestDispatcherImpl.include(RequestDispatcherImpl.java:358)
    at com.caucho.jsp.PageContextImpl.include(PageContextImpl.java:1008)
    at com.caucho.jsp.PageContextImpl.include(PageContextImpl.java:943)
    at com.opensymphony.module.sitemesh.taglib.page.ApplyDecoratorTag.doEndTag(ApplyDecoratorTag.java:256)
    at _jsp._404__jsp._jspService(_404__jsp.java:152)
    at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
    at com.caucho.jsp.Page.pageservice(Page.java:578)
    at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:195)
    at com.caucho.server.webapp.DispatchFilterChain.doFilter(DispatchFilterChain.java:97)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
    at com.caucho.server.webapp.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:283)
    at com.caucho.server.webapp.RequestDispatcherImpl.error(RequestDispatcherImpl.java:115)
    at com.caucho.server.webapp.ErrorPageManager.handleErrorStatus(ErrorPageManager.java:610)
    at com.caucho.server.webapp.ErrorPageManager.sendError(ErrorPageManager.java:493)
    at com.caucho.server.connection.AbstractHttpResponse.sendError(AbstractHttpResponse.java:523)
    at com.caucho.server.connection.AbstractHttpResponse.sendError(AbstractHttpResponse.java:477)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:99)
    at org.springframework.security.context.HttpSessionContextIntegrationFilter$OnRedirectUpdateSessionResponseWrapper.sendError(HttpSessionContextIntegrationFilter.java:489)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:99)
    at net.sf.ehcache.constructs.web.GenericResponseWrapper.sendError(GenericResponseWrapper.java:105)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:99)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:99)
    at com.opensymphony.module.sitemesh.filter.PageResponseWrapper.sendError(PageResponseWrapper.java:175)
    at org.springframework.web.servlet.DispatcherServlet.noHandlerFound(DispatcherServlet.java:1071)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:856)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)

Notes
(0003573)
tempestse   
12-01-08 22:05   
BTW: the referenced ticket 0002883 is not mine, so this issue is affecting at the very least two different Resin users.
(0003856)
smallufo   
03-02-09 11:57   
I have exactly the same error message with resin-3.1.6 and spring-framework-2.5.5.

I just want to get HttpServletRequest from my bean :

The following single line triggers the exception :

ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
System.out.println("ServletRequestAttributes = " + sra);

ServletRequestAttributes is correctly retrieved , and printed :
ServletRequestAttributes = HttpRequest[34]

But the exception is thrown and logged...

[03:54:32.322] java.lang.NullPointerException
[03:54:32.322] at com.caucho.server.connection.RequestWrapper.isSecure(RequestWrapper.java:296)
[03:54:32.322] at com.caucho.server.connection.RequestAdapter.getCookieName(RequestAdapter.java:463)
[03:54:32.322] at com.caucho.server.connection.RequestAdapter.getSession(RequestAdapter.java:387)
[03:54:32.322] at com.caucho.server.webapp.DispatchRequest.getSession(DispatchRequest.java:448)
[03:54:32.322] at org.springframework.web.context.request.ServletRequestAttributes.updateAccessedSessionAttributes(ServletRequestAttributes.java:213)
[03:54:32.322] at org.springframework.web.context.request.AbstractRequestAttributes.requestCompleted(AbstractRequestAttributes.java:49)
[03:54:32.322] at org.springframework.web.context.request.RequestContextListener.requestDestroyed(RequestContextListener.java:87)
[03:54:32.322] at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:197)
[03:54:32.322] at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
[03:54:32.322] at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:270)
[03:54:32.322] at com.caucho.server.port.TcpConnection.run(TcpConnection.java:678)
[03:54:32.322] at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)
[03:54:32.322] at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)
[03:54:32.322] at java.lang.Thread.run(Thread.java:619)
(0003859)
smallufo   
03-03-09 06:55   
Sorry for my previous post .
Now , I can pinpoint the problem.

The problem comes from Spring's RequestContextListener.

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

Once it is registered in web.xml , each web request will triggger the NPE :


The following exception results from Resin 3.2.1 with Spring 2.5.5 :

[22:51:40.869] {http--8080-1} java.lang.NullPointerException
[22:51:40.869] {http--8080-1} at com.caucho.server.connection.RequestWrapper.isSecure(RequestWrapper.java:292)
[22:51:40.869] {http--8080-1} at com.caucho.server.connection.RequestAdapter.getCookieName(RequestAdapter.java:473)
[22:51:40.869] {http--8080-1} at com.caucho.server.connection.RequestAdapter.getSession(RequestAdapter.java:397)
[22:51:40.869] {http--8080-1} at com.caucho.server.webapp.DispatchRequest.getSession(DispatchRequest.java:448)
[22:51:40.869] {http--8080-1} at org.springframework.web.context.request.ServletRequestAttributes.updateAccessedSessionAttributes(ServletRequestAttributes.java:213)
[22:51:40.869] {http--8080-1} at org.springframework.web.context.request.AbstractRequestAttributes.requestCompleted(AbstractRequestAttributes.java:49)
[22:51:40.869] {http--8080-1} at org.springframework.web.context.request.RequestContextListener.requestDestroyed(RequestContextListener.java:87)
[22:51:40.869] {http--8080-1} at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:199)
[22:51:40.869] {http--8080-1} at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
[22:51:40.869] {http--8080-1} at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:292)
[22:51:40.869] {http--8080-1} at com.caucho.server.port.TcpConnection.handleRequests(TcpConnection.java:577)
[22:51:40.869] {http--8080-1} at com.caucho.server.port.TcpConnection$AcceptTask.doAccept(TcpConnection.java:1211)
[22:51:40.869] {http--8080-1} at com.caucho.server.port.TcpConnection$AcceptTask.run(TcpConnection.java:1152)
[22:51:40.869] {http--8080-1} at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:759)
[22:51:40.869] {http--8080-1} at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:681)
[22:51:40.869] {http--8080-1} at java.lang.Thread.run(Thread.java:619)
(0004103)
tempestse   
07-27-09 15:21   
I've upgraded to Resin 3.1.9 (pro) and this issue remains.
(0004122)
ferg   
08-13-09 17:52   
server/10gv