I have a Servlet method that as follows that is meant to do no more then forward
to a test JSP page called WibbleWobble

-----------------------------------------------------------------------------------------------------------------

     protected void doPost(
          HttpServletRequest request,
          HttpServletResponse response)
               throws ServletException, java.io.IOException
     {
          System.out.println ("Starting : " +new Date());
          try
          {

               String forwardURL = ("/WibbleWobble.jsp");
               RequestDispatcher dispatcher = request.getRequestDispatcher(
forwardURL );
          dispatcher.forward(request, response );


          }
          catch (Exception e)
          {
               System.out.println("Exception thrown");
               throw new RemoteException( "Exception ",e );
          }
          System.out.println ("Leaving : " +new Date());
     }


-----------------------------------------------------------------------------------------------------------------



Which when run with test case as follows

    public void testXYZABC() throws IOException, Exception
    {
        SecurityServlet servlet = new SecurityServlet();
        servlet.init(config);
        servlet.doPost( request, response );

    }

Gives me the following error

java.rmi.RemoteException: Exception ; nested exception is:
     java.lang.ClassCastException:
org.apache.commons.cactus.server.HttpServletRequestWrapper
java.lang.ClassCastException:
org.apache.commons.cactus.server.HttpServletRequestWrapper
     at
org.apache.tomcat.facade.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:144)
     at SecurityServlet.doPost(SecurityServlet.java:127)
     at TestSecurityServlet.testXYZABC(TestSecurityServlet.java:177)
     at
org.apache.commons.cactus.AbstractTestCase.runServerTest(AbstractTestCase.java:313)
     at
org.apache.commons.cactus.AbstractTestCase.runBareServerTest(AbstractTestCase.java:284)
     at
org.apache.commons.cactus.server.ServletTestCaller.callTestMethod(ServletTestCaller.java:139)
     at
org.apache.commons.cactus.server.ServletTestCaller.doTest(ServletTestCaller.java:173)
     at
org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java:116)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
     at org.apache.tomcat.core.Handler.service(Handler.java:286)
     at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
     at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
     at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
     at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
     at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
     at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
     at java.lang.Thread.run(Thread.java:484)

However the servlet method is invoked through the Browser it works fine and
forwards to the Web Page correctly.
Does anyone have any ideas. Because this is a major problem to me.




******************************************************************************************************************************************************
This e-mail has been prepared using information  believed  by  the  author
to be reliable and accurate, but CWB makes  no  warranty  as to accuracy or
completeness. In particular CWB does not  accept  responsibility  for
changes  made to this e-mail after it was sent.  Any  opinions expressed in
this document are those of the author and do  not  necessarily reflect the
opinions of the company or its affiliates. They may be subject to change
without notice.
*******************************************************************************************************************************************************


Reply via email to