This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Request is null when Request Wrapper is used in filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Request is null when Request Wrapper is used in filter" Watch "Request is null when Request Wrapper is used in filter" New topic
Author

Request is null when Request Wrapper is used in filter

Ruhul Mazumder
Greenhorn

Joined: Sep 26, 2006
Posts: 5
Hi ALL,

Our application has multipart form and normal form. We are using servlet filter for doing authentication and authorization. For multipart for we are creating request multipart wrapper to do multiple read of multipart data. Everything works fine but sometimes we get null pointer exception while setting attribute in servlets (whenrequest is a multipart wrapper ).

In wrapper we are getting the input stream and storing it in byte array and overring getReader() and getInputStream() to use the byte array

Below is the stack trace,

Jan 13, 2012 10:05:27 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [XXXServlet] in context with path [/XXXX] threw exception
java.lang.NullPointerException
at org.apache.catalina.connector.Request.setAttribute(Request.java:1563)
at org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:543)
at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:239)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:285)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.xxx.filter.webfilter.XXXNFilter.doFilter(XXXNFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

Please let me know if anyone has face same error and how to solve this issue.

Thanks in Advanced,
Ruhul
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request is null when Request Wrapper is used in filter
 
jQuery in Action, 3rd edition