You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Peter <pe...@xml-asia.org> on 2003/05/02 12:53:24 UTC
cactus problem
Hi All,
When I run a ServletTestCase to test Servlet which will dispatch request to another jsp. Exception is caught when I run the test:
2003-05-02 18:30:25,600 [ExecuteThread: '12' for queue: 'default'] DEBUG - <forw
ard([com.shk.jaf.application.afc.ui.HttpRequestWrapper@aefbe1], [com.shk.jaf.app
lication.afc.ui.filter.HttpResponseWrapper@135fad1])
java.lang.ClassCastException
at org.apache.cactus.server.RequestDispatcherWrapper.dispatch179_forward
(RequestDispatcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1k):102)
at org.apache.cactus.server.RequestDispatcherWrapper.around179_forward(R
equestDispatcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1149)
at org.apache.cactus.server.RequestDispatcherWrapper.forward(RequestDisp
atcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1k):99)
at com.shk.jaf.application.afc.ui.Gateway.doProcess(Unknown Source)
at com.shk.jaf.application.afc.ui.Gateway.doPost(Unknown Source)
at com.shk.jaf.application.afc.ui.test.UIFlowTest.testUIFlow(Unknown Sou
rce)
For my code, both HttpRequestWrapper and HttpResponseWrapper are class extends HttpServletRequestWrapper and HttpServletResponseWrapper respectively. Any idea and solution to solve the problem?
Thanks
brgds Peter
RE: cactus problem
Posted by Vincent Massol <vm...@pivolis.com>.
Hi Peter,
The cactus code related to your problem is the following:
public void forward(ServletRequest theRequest, ServletResponse
theResponse)
throws IOException, ServletException
{
HttpServletRequestWrapper request =
(HttpServletRequestWrapper) theRequest;
[...]
where the request wrapper is a Cactus class (and not the Servlet 2.3
request wrapper).
The cast is where it fails. However, the request you use should be the
implicit object provided by the ServletTestCase class which is of type
HttpServletRequestWrapper. So that's not the problem.
I believe you must be wrapping the request in a class that does not
extend the Cactus HttpServletRequestWrapper
(com.shk.jaf.application.afc.ui.HttpRequestWrapper), hence the reason
the cast fails.
Most of the containers require that you pass the original request to the
forward method. You'll need to provide a getOriginalRequest() method in
your HttpRequestWrapper and use it when you call the forward method.
Hope it helps,
-Vincent
-----Original Message-----
From: Peter [mailto:peter.kwong@xml-asia.org]
Sent: 02 May 2003 12:53
To: cactus-user@jakarta.apache.org
Subject: cactus problem
Hi All,
When I run a ServletTestCase to test Servlet which will dispatch request
to another jsp. Exception is caught when I run the test:
2003-05-02 18:30:25,600 [ExecuteThread: '12' for queue: 'default'] DEBUG
- <forw
ard([com.shk.jaf.application.afc.ui.HttpRequestWrapper@aefbe1],
[com.shk.jaf.app
lication.afc.ui.filter.HttpResponseWrapper@135fad1])
java.lang.ClassCastException
at
org.apache.cactus.server.RequestDispatcherWrapper.dispatch179_forward
(RequestDispatcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1
k):102)
at
org.apache.cactus.server.RequestDispatcherWrapper.around179_forward(R
equestDispatcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1k)
:1149)
at
org.apache.cactus.server.RequestDispatcherWrapper.forward(RequestDisp
atcherWrapper.java;org/apache/cactus/util/log/LogAspect.aj(1k):99)
at com.shk.jaf.application.afc.ui.Gateway.doProcess(Unknown
Source)
at com.shk.jaf.application.afc.ui.Gateway.doPost(Unknown Source)
at
com.shk.jaf.application.afc.ui.test.UIFlowTest.testUIFlow(Unknown Sou
rce)
For my code, both HttpRequestWrapper and HttpResponseWrapper are class
extends HttpServletRequestWrapper and HttpServletResponseWrapper
respectively. Any idea and solution to solve the problem?
Thanks
brgds Peter