Bug 43669 - ApplicationDispatcher.unwrapRequest raises "cannot be cast to javax.servlet.ServletRequestWrapper"
Summary: ApplicationDispatcher.unwrapRequest raises "cannot be cast to javax.servlet.S...
Status: RESOLVED DUPLICATE of bug 39417
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.24
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-21 13:36 UTC by Mailmur
Modified: 2007-10-21 13:52 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mailmur 2007-10-21 13:36:09 UTC
Tomcat 5.5.x:
http://svn.apache.org/repos/asf/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/core/ApplicationDispatcher.java
  private void unwrapRequest(State state) {
    ...continue...
    // Advance to the next request in the chain
    previous = current;
    current = ((ServletRequestWrapper) current).getRequest(); // !! CAST ERROR
    ...continue...
  }

Exception is thrown when request is forwarded:
  "com.outerrim.servlet.OfflineHttpServletRequest cannot be cast to 
   javax.servlet.ServletRequestWrapper"

This is my offlineHttpServletRequest and Response classes:
  public class OfflineHttpServletRequest implements HttpServletRequest { ... }
  public class OfflineHttpServletResponse implements HttpServletResponse { ... }

They provide me a way to call servlet urls without the real webclient requests.
This is used in a background thread, that must trigger "dispatcher.forward(req,
res)" method call.
   RequestDispatcher dispatcher = ctx.getRequestDispatcher(url);
   dispatcher.forward(offReq, offRes);

Classes work fine in Tomcat5.0.x releases. 

Is it really a new requirement, that customized classes must inherit
ServletRequestWrapper/ServletResponseWrapper classes?
Comment 1 Mailmur 2007-10-21 13:46:47 UTC

*** This bug has been marked as a duplicate of 39417 ***
Comment 2 Mailmur 2007-10-21 13:52:10 UTC
And to comment what happened to my forward.request. Yes, it worked fine and went
to the destination webapplication url. But then applicationdispatcher tries to
roll back to the caller, it fails due to a ClassCastException.