• 2 replies
  • Latest Post - ‏2012-05-16T07:13:13Z by X75J_Li_Yanli
2233 Posts

Pinned topic IllegalStateException in my local URL rewrite filtering

‏2011-10-31T08:26:47Z |
Hello all,

I am developing a system on WAS CE (not the latest one for a contract reason). I am using our own very simple URL rewrite filtering component (for copyright reason). It has only simple forwarding function and successfully runs on WAS 7.0 and Tomcat. But its filtering on WAS CE sometimes fails with the following exception:

java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(
at org.apache.catalina.core.ApplicationDispatcher.forward(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(
at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(
at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.geronimo.tomcat.valve.ThreadCleanerValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(

I set only one filter in the web.xml of my system as follows. I also attach our URL rewrite filter codes:


The trace log says that the isCommitted flag has already been true when the filter is invoked as follows:

2011-10-31 17:15:44,590 TRACE http- Returning non-STM instance
2011-10-31 17:15:44,591 DEBUG http- Response has been already committed!!!

The second log is written just after UrlRewriteFilter.doFilter is invoked. I think there is another hidden filter which handles the response but I can't find it even in the detailed trace log using log4j.

Could anyone let me know what happens and what is wrong?

Thanks a lot in advance...
Updated on 2012-05-16T07:13:13Z at 2012-05-16T07:13:13Z by X75J_Li_Yanli
  • Forrest_Xia
    82 Posts

    Re: IllegalStateException in my local URL rewrite filtering

    Can you provide a runnable sample with this issue? so that we can investigate it easily.

  • X75J_Li_Yanli
    45 Posts

    Re: IllegalStateException in my local URL rewrite filtering


    1. According to your sample, I created a dynamic web project like yours which including a servlet named UrlRewriter, two java files named UrlRewriteFilter and UrlRewriteRule.

    2 .I also created two web pages named index.html and test.jsp, if access index.html it will print "Say Hello!" on web page, if access test.jsp, it will print "Say Hello JSP!"

    3. I also add the urlwrite.xml which is the same role of file urlrewriterules.xml that you mentioned in class UrlRewriter:
    InputStream is = context.getResourceAsStream("/WEB-INF/urlrewriterules.xml");

    4. For the urlwrithe.xml, the content is simple and like this:
    <?xml version="1.0" encoding="utf-8"?>
    <name>Test Rule1</name>
    <note>A test rule to show a simple redirect.</note>
    <to type="redirect">/test.jsp</to>

    5.Export the project as a WAR, and deployed on wasce, and access the url:
    Then you can see the result is :
    Say Hello JSP!
    And can't reproduce this problem as you described.

    6. The project I created is attached and please support your urlrewriterules.xml file which will be helpful to reproduce this problem.