java.lang.IllegalStateException: Response already committed

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • BPM Workspace and Composer login problem
    via by 380288f9-7f88-44ae-bb5e-10c861cf2917,
  • BPM Workspace Issue.
    via by kasiraju.rudraraju,
  • BPM workspace login failed
    via by Ravi Kapur,
  • From the javadoc for ExternalContext.redirect(): http://docs.oracle.com/javaee/6/api/javax/faces/context/ExternalContext.html#redirect%28java.lang.String%29 "Throws: IllegalStateException - if, in a servlet environment, the current response has already been committed" This works fine for full page refresh / submit. We see this exception when attempting to write to response stream after response is complete: java.lang.IllegalStateException: Response already committed at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1608) at weblogic.servlet.internal.ServletResponseImpl.sendRedirect(ServletResponseImpl.java:834) at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:136) at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:421) However for Partial page submit / AJAX case, this exception is not raised, and there is possibility of writing to response even after the response is logically complete. The bug is evident looking at the implementation of redirect() method in ExternalContext: 549 /** 550 * @see ExternalContext#redirect(String) 551 */ 552 public void redirect(String requestURI) throws IOException { 553 554 FacesContext ctx = FacesContext.getCurrentInstance(); 555 getELFlash().doLastPhaseActions(ctx, true); 556 557 if (ctx.getPartialViewContext().isAjaxRequest()) { 558 PartialResponseWriter pwriter; 559 ResponseWriter writer = ctx.getResponseWriter(); 560 if (writer instanceof PartialResponseWriter) { 561 pwriter = (PartialResponseWriter) writer; 562 } else { 563 pwriter = ctx.getPartialViewContext().getPartialResponseWriter(); 564 } 565 setResponseContentType("text/xml"); 566 setResponseCharacterEncoding("UTF-8"); 567 addResponseHeader("Cache-Control", "no-cache"); 568 pwriter.startDocument(); 569 pwriter.redirect(requestURI); 570 pwriter.endDocument(); 571 } else { 572 ((HttpServletResponse) response).sendRedirect(requestURI); 573 } 574 ctx.responseComplete(); 575 576 } The Servlet specification essentially says that sendRedirect() commits the request, so a second sendRedirect() will throw an IllegalStateException. For the AJAX case, looks like the above implementation is simply using a redirect header and is likely rendering content to perform the redirect. Furthermore looks like for AJAX case call to redirect() does not result in calling FacesContext.responseComplete(), which is not right. The consequence of this is bug in JSF based applications that in AJAX case, the response can contain as many redirects as possible, which is invalid to do so. Expected: Mojarra should implement the redirect semantics correctly and completely for the partial rendering / AJAX case as is done for the full page refresh case. Testcase: Code like the following when executed for AJAX request should show the issue: ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext(); HttpSession session = (HttpSession)ectx.getSession(true); String temp = session.getServletContext().getContextPath() + "/faces/welcomePage.jspx"; String temp2 = session.getServletContext().getContextPath() + "/faces/mainPage.jspx"; try { boolean complete1 = FacesContext.getCurrentInstance().getResponseComplete(); ectx.redirect(temp); boolean complete2 = FacesContext.getCurrentInstance().getResponseComplete(); ectx.redirect(temp2); boolean complete3 = FacesContext.getCurrentInstance().getResponseComplete(); } catch (Exception ex) { ex.printStackTrace(); }
    via by prakashudupa,
    • java.lang.IllegalStateException: Response already committed at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1608) at weblogic.servlet.internal.ServletResponseImpl.sendRedirect(ServletResponseImpl.java:834) at javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:136) at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:421) at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:303) at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:303) at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:303) at oracle.adfinternal.view.faces.config.rich.DetectRedirect.redirect(DetectRedirect.java:47) at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:303) at org.apache.myfaces.trinidad.context.ExternalContextDecorator.redirect(ExternalContextDecorator.java:303) at oracle.adf.view.rich.context.UriManagerBase.addQueryParameters(UriManagerBase.java:43) at oracle.adfinternal.view.faces.webapp.rich.UriManagerImpl.addQueryParameters(UriManagerImpl.java:28) at oracle.adfinternal.controller.util.AdfvInterfaceImpl.addQueryParameters(AdfvInterfaceImpl.java:168) at oracle.adfinternal.controller.state.ControllerState.initializeUrl(ControllerState.java:683) at oracle.adfinternal.controller.state.ControllerState.synchronizeStatePart2(ControllerState.java:447) at oracle.adfinternal.controller.application.SyncNavigationStateListener.afterPhase(SyncNavigationStateListener.java:46) at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:531) at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:120) at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:168) at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent(ADFPhaseListener.java:124) at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:70) at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:398) at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:185) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.help.web.rich.OHWFilter.doFilter(Unknown Source) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.bpel.worklistapp.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:209) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446) at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271) at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177) at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111) at java.security.AccessController.doPrivileged(Native Method) at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313) at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413) at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94) at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161) at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    4 more bugmates