jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kazuhito SUGURI <suguri.kazuh...@lab.ntt.co.jp>
Subject Re: java.lang.NullPointerException and RequestDispatcherWrapper.forward_aroundBody0
Date Thu, 30 Sep 2004 05:54:57 GMT

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 {

I guess testCommand() fails and/or your expectedUrl is not valid
for your container.

Hope this helps,
Kazuhito SUGURI

View raw message