Once again – Response already committed

Splash Forums Rewrite Users Once again – Response already committed

This topic contains 1 reply, has 1 voice, and was last updated by  Ultranium 11 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27238

    Ultranium
    Participant

    Hi, I’m new to Rewrite and I’m just trying to make my test application work with it using simple redirect rules.

    But for every redirect event I’m getting “Response already committed” error in log, in spite of redirect works well and I can see target page in my browser.
    I checked it with Glassfish 4.1 and Wildfly 9 – the problem is same. I already read this thread – https://github.com/ocpsoft/rewrite/issues/151 , but the workaround doesn’t work for me. I’m using the latest stable version of Rewrite – 2.0.12.Final by Maven.

    Here is stack trace for Wildfly:

    14:26:17,805 ERROR [io.undertow.request] (default task-4) UT005023: Exception handling request to /untitled65_war_exploded/index.xhtml: java.lang.IllegalStateException: UT010019: Response already commited
    	at io.undertow.servlet.spec.ServletOutputStreamImpl.resetBuffer(ServletOutputStreamImpl.java:715)
    	at io.undertow.servlet.spec.HttpServletResponseImpl.resetBuffer(HttpServletResponseImpl.java:483)
    	at javax.servlet.ServletResponseWrapper.resetBuffer(ServletResponseWrapper.java:241)
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.resetBuffer(HttpRewriteWrappedResponse.java:480)
    	at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:147)
    	at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:108)
    	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:41)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:268)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188)
    	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
    	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
    	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
    	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
    	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
    	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
    	at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
    	at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
    	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
    	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
    	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
    	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
    	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
    	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)

    ExampleConfigurationProvider.java:

    @RewriteConfiguration
    public class ExampleConfigurationProvider extends HttpConfigurationProvider
    {
        @Override
        public int priority()
        {
            return 10;
        }
    
        @Override
        public Configuration getConfiguration(final ServletContext context)
        {
            return ConfigurationBuilder.begin()
                    .addRule()
                    .when(Direction.isInbound().and(Path.matches("/test")))
                    .perform(Forward.to("/index.xhtml"))
    
                    .addRule()
                    .when(Response.isCommitted())
                    .perform(Lifecycle.abort());
    
        }
    }

    web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1">
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
    </web-app>
    #27239

    Ultranium
    Participant

    Sorry, but I’ve already solved the problem by myself.
    I definitely should’ve pay more attention to the Rewrite documentation.

    The problem was with dependencies – I included all rewrite-* JARs from Maven to my application.
    Now I left only rewrite-servlet.jar and everything works fine!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.