Mantis - Resin
Viewing Issue Advanced Details
4761 minor always 09-13-11 09:43 10-04-11 15:24
stbu  
ferg  
normal  
closed 4.0.22  
fixed  
none    
none 4.0.24  
0004761: NullPointerException in WebApp.getRealPath
The following piece of JSP code (sample) produces a NullPointerException in Resin's Code for implementation of ServletContext.getRealPath:

<%
 pageContext.getServletContext().getRealPath((String) request.getAttribute("javax.servlet.error.request_uri"));
%>

but the Servlet 2.5 Spec contains the following about getRealPath:

<quote>
This method returns null if the servlet container cannot translate the virtual path to a real path for ***any reason*** ...
</quote>


And any reason includes NULL as argument?
This happens if
   request.getAttribute("javax.servlet.error.request_uri")
returns null itself, e.g. when there is no error in a request.

It would be better and compliant to the 2.5 Servlet Spec if WebApp.getRealPath() would just return null.
Stack Trace in Resin 4.0.22:

java.lang.NullPointerException
    at com.caucho.server.webapp.WebApp.getRealPath(WebApp.java:4318)
    at _jsp._real_22dpath_22dtest__jsp._jspService(real-path-test.jsp:2)
    at _jsp._real_22dpath_22dtest__jsp._jspService(_real_22dpath_22dtest__jsp.java:29)
    at com.caucho.jsp.JavaPage.service(JavaPage.java:64)
    at com.caucho.jsp.Page.pageservice(Page.java:542)
    at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:194)
    at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:156)
    at com.caucho.server.webapp.AccessLogFilterChain.doFilter(AccessLogFilterChain.java:95)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:289)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:811)
    at com.caucho.network.listen.TcpSocketLink.dispatchRequest(TcpSocketLink.java:1203)
    at com.caucho.network.listen.TcpSocketLink.handleRequest(TcpSocketLink.java:1164)
    at com.caucho.network.listen.TcpSocketLink.handleRequestsImpl(TcpSocketLink.java:1148)
    at com.caucho.network.listen.TcpSocketLink.handleRequests(TcpSocketLink.java:1071)
    at com.caucho.network.listen.TcpSocketLink.handleAcceptTask(TcpSocketLink.java:907)
    at com.caucho.network.listen.AcceptTask.doTask(AcceptTask.java:74)
    at com.caucho.network.listen.ConnectionTask.runThread(ConnectionTask.java:97)
    at com.caucho.network.listen.ConnectionTask.run(ConnectionTask.java:80)
    at com.caucho.network.listen.AcceptTask.run(AcceptTask.java:59)
    at com.caucho.env.thread.ResinThread.runTasks(ResinThread.java:164)
    at com.caucho.env.thread.ResinThread.run(ResinThread.java:130)


Stack Trace in Resin 3.1.11:

java.lang.NullPointerException
    at com.caucho.server.webapp.WebApp.getRealPath(WebApp.java:2456)
    at _jsp._real_22dpath_22dtest__jsp._jspService(real-path-test.jsp:2)
    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.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
    at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)
    at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)
    at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)
    at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)
    at java.lang.Thread.run(Thread.java:619)

Notes
(0005535)
ferg   
10-04-11 15:24   
server/10m7