Hi ! Eventually I am getting the following StackOverflowError in Tomcat 6.0.29, and after walking through this StackTrace, and source code of Tomcat 6.0.29, I found ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:278) as a recursive method call from javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284). The piece of code from ServletRequestWrapper.java looks like : public void setAttribute(String name, Object o) { this.request.setAttribute(name, o); } So in this piece of code is it necessary to do a equality check for the request object just to make sure this will never went into a recursion even though the user calls a setAttribute(name, o) on a WrappedRequest object(ServletRequestWrapper). Following is the Error Stack Trace : java.lang.StackOverflowError at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:278) at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:279) at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:279) . ...repeated many times.. . at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:279) at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:279) at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284) at com.kony.web.controller.KonyBaseServlet.logUserDetails(Unknown Source) at com.kony.web.controller.KonyBaseServlet.navigateToNextForm(Unknown Source) at com.kony.web.controller.KonyWebWAPController.processRequest(Unknown Source) at com.kony.web.controller.KonyWebWAPController.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:279) at javax.servlet.ServletRequestWrapper.setAttribute(ServletRequestWrapper.java:284) at com.kony.web.controller.KonyBaseServlet.logUserDetails(Unknown Source) at com.kony.web.controller.KonyBaseServlet.navigateToNextForm(Unknown Source) at com.kony.web.controller.KonyWebWAPController.processRequest(Unknown Source) at com.kony.web.controller.KonyWebWAPController.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) . .Repeated many times.... . at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at com.kony.web.controller.KonyBaseServlet.navigateToNextForm(Unknown Source) at com.kony.web.controller.KonyWebWAPController.processRequest(Unknown Source) at com.kony.web.controller.KonyWebWAPController.doPost(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) So is this a bug , if yes is there any fix release n this and if not am I misinterpreting anything, please guide me where I am doing so.
Looks like something in your app is calling setRequest() on a wrapper and passing in the wrapper rather than the request to be wrapped. The Servlet specification does not provide for throwing an exception in this case. I'll add that to my list of things to raise for the next version of the spec.
Mark thanks for your response. I have used following kinda methods at many places in my app. protected void logUserDetails(HttpServletRequest request){ request.setAttribute("APP_ID", "myappid"); } But surprisingly this StackOverflowError is coming randomly around 3 times in a month and these methods are serving fine to rest all request with out any StackOverFlowError. SO here am looking for your help to understand in which scenario this request object becoming an instance of ServletRequestWrapper and undergoing that recursion. Also one more doubt I have, are we not suppose to call the setAttribute() and getAttribute() methods of ServletRequestWrapper. (In reply to comment #1) > Looks like something in your app is calling setRequest() on a wrapper and > passing in the wrapper rather than the request to be wrapped. The Servlet > specification does not provide for throwing an exception in this case. I'll add > that to my list of things to raise for the next version of the spec.
Also one more observation is : We never got such error before we upgraded our application from Tomcat 6.0.18 to Tomcat 6.0.29
Hi Mark sorry for sharing the information in multiple chunk. From the org.apache.catalina.core.ApplicationDispatcher.java from the invoke method is there any chance that the following lines of code may not execute and we may be getting an ServletRequestWrapper object leading to the recursion. ApplicationDispatcher.java(Line No : 722 to 725) // Unwrap request/response if needed // See Bugzilla 30949 unwrapRequest(state); unwrapResponse(state); Thanks Ashish
The users list is the place to seek help.