You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "bognár, attila" <at...@netalfa.com> on 2003/04/19 23:37:28 UTC

ErrorReportValve, (ServletRequest)request

hello,

I am new to tomcat regarding 'advanced' features, especially regarding 
to topics closer to the core. I had to write a valve that extract 
X-Forwarded-For header from request. For this task I created a wrapper 
HttpRequest, which returns an RPAFHttpServletRequest as the getRequest() 
result. (see tomcat-user@ list - my last problem is - partly - solved by 
commenting lifecycle configuration from server.xml).

Now tomcat goes further with starting up, but still has errors:

2003-04-19 22:50:01 CoyoteAdapter An exception or error occurred in the 
container during the request processing
java.lang.ClassCastException: com.netalfa.tomcat.valves.RPAFHttpRequest
         at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:174)
         at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
         at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at com.netalfa.tomcat.valves.RPAFValve.invoke(RPAFValve.java:54)
         at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at 
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:484)


now, int the source of ErrorReportValve:

     public void invoke(Request request, Response response,
                        ValveContext context)
         throws IOException, ServletException {

         // Perform the request
         context.invokeNext(request, response);

         ServletRequest sreq = (ServletRequest) request;
         Throwable throwable =
             (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR);

         ServletResponse sresp = (ServletResponse) response;
...

how legal are the two castings? ((ServletRequest) request and 
(ServletResponse) response). I think not at all. If I don't wrap the 
original request in my valve, the request is an instance of 
CoyoteRequest, which implements both HttpRequest and HttpServletRequest, 
so there is no problem. But I don't think it should be expected, that 
the request implements HttpRequest too, instead request.getRequest() 
should be called to get the appropriate HttpRequest.


thanks,

attila


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: ErrorReportValve, (ServletRequest)request

Posted by Tim Funk <fu...@joedog.org>.
See my response in tomcat-user.

-Tim

bognár, attila wrote:
> hello,
> 
> I am new to tomcat regarding 'advanced' features, especially regarding 
> to topics closer to the core. I had to write a valve that extract 
> X-Forwarded-For header from request. For this task I created a wrapper 
> HttpRequest, which returns an RPAFHttpServletRequest as the getRequest() 
> result. (see tomcat-user@ list - my last problem is - partly - solved by 
> commenting lifecycle configuration from server.xml).
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org