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 <[EMAIL PROTECTED]>,
Wed, 29 Sep 2004 15:54:43 +0100,
Mamadou Cisse <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Regards,
Mamadou Cisse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Alatto Technologies www.alatto.com t: + 353 1 209 0785 f: + 353 1 209 0707 email: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
