jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mamadou Cisse <mamadou.ci...@alatto.com>
Subject Re: java.lang.NullPointerException and RequestDispatcherWrapper.forward_aroundBody0
Date Thu, 30 Sep 2004 08:50:43 GMT
Hi Kazuhito and All the others.
I went through the code in the debugger. The thing is that the returned 
instance of the RequestDispatcher is NON-NULL, but this instance has an 
instance variable called originalDispatcher which is NULL and I believe 
this to be the cause of the problem.
Before instanciating a test suite, I set the cactus.contextURL to 
http://localhost:aport/mycontext using a call to System.setProperty:
        System.setProperty("cactus.contextURL", 
"http://localhost:aport/mycontext");
So the question is why originalDispatcher in the returned 
RequestDispatcher is set to null when a Cactus instanciated 
HttpServletRequestWrapper  is passed to a servlet's doPost method, which 
in turn calls getRequestDispatcher on the HttpRequestDispatcherWrapper 
instance?

Regards,
Mamadou.

>Hi,
>
>In article <415ACCB3.80305@alatto.com>,
>Wed, 29 Sep 2004 15:54:43 +0100,
>Mamadou Cisse <mamadou.cisse@alatto.com> wrote: 
>mamadou> In doPost a command object is created from the parameter request. This 
>mamadou> command object does some processing and then returns a String as URL to 
>mamadou> the doPost method which in turn tries to forward the call. The 
>mamadou> pseudocode looks like:
>mamadou> {pseudocode ---
>mamadou> Command command = CommandFactory.getCommand(request), //1
>mamadou> String urlStr = command.execute(); //2
>mamadou> RequestDispatcher disp = request.getRequestDispatcher(urlStr); //3
>mamadou> disp.forward(request, response); //4
>mamadou> --- pseudocode}
>mamadou> On the line //4 there is a NullPointerException. The reason is that the 
>mamadou> originalDispatcher in the RequestDispatcher instance is null.
>
>ServletRequest#getRequestDispatcher(String) returns null
>if the servlet container cannot return a RequestDispatcher.
>So, I think, the point is that the urlStr value returned from command.execute()
>is valid or not.
>
>You might separate the test into some parts like:
>    public void testCommand {
>        Command command = CommandFactory.getCommand(request);
>        assertEquals("expectedUrl", command.execute());
>    }
>    public void testDispatch {
>        assertNotNull(request.getRequestDispatcher("expectedUrl"));
>    }
>
>I guess testCommand() fails and/or your expectedUrl is not valid
>for your container.
>
>Hope this helps,
>----
>Kazuhito SUGURI
>mailto:suguri.kazuhito@lab.ntt.co.jp
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: cactus-user-help@jakarta.apache.org
>
>
>  
>


-- 
Regards,

Mamadou Cisse
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Alatto Technologies
www.alatto.com
t: + 353 1 209 0785
f: + 353 1 209 0707
email: mamadou.cisse@alatto.com



Mime
View raw message