java.lang.IllegalStateException: Response already committed

Oracle Community | user540571 | 2 years ago
  1. 0

    oracle service bus 12c sbconsole not accessible 401

    Oracle Community | 2 years ago | user540571
    java.lang.IllegalStateException: Response already committed
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    db:: 4.40::BEA-101020 error ac

    hivmr.com | 2 months ago
    java.lang.IllegalStateException: Response already committed
  4. 0

    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(); }

    Java.net JIRA | 4 years ago | prakashudupa
    java.lang.IllegalStateException: Response already committed

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      Response already committed

      at weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted()
    2. Atmosphere weblogic
      ServletResponseImpl.sendRedirect
      1. weblogic.servlet.internal.ServletResponseImpl.objectIfCommitted(ServletResponseImpl.java:1725)
      2. weblogic.servlet.internal.ServletResponseImpl.sendRedirect(ServletResponseImpl.java:922)
      3. weblogic.servlet.internal.ServletResponseImpl.sendRedirect(ServletResponseImpl.java:918)
      3 frames
    3. JavaServlet
      HttpServletResponseWrapper.sendRedirect
      1. javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:168)
      1 frame
    4. JSF
      ExternalContextImpl.redirect
      1. com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl.java:576)
      1 frame
    5. JavaEE 7
      ExternalContextWrapper.redirect
      1. javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
      2. javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
      3. javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
      4. javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
      4 frames
    6. oracle.adfinternal.view
      DetectRedirect.redirect
      1. oracle.adfinternal.view.faces.config.rich.DetectRedirect.redirect(DetectRedirect.java:66)
      1 frame
    7. JavaEE 7
      ExternalContextWrapper.redirect
      1. javax.faces.context.ExternalContextWrapper.redirect(ExternalContextWrapper.java:462)
      1 frame
    8. oracle.adfinternal.controller
      AdfcExceptionHandler.handleException
      1. oracle.adfinternal.controller.util.JsfInterfaceImpl.redirectToUrl(JsfInterfaceImpl.java:100)
      2. oracle.adfinternal.controller.util.JsfInterfaceImpl.redirectToViewId(JsfInterfaceImpl.java:85)
      3. oracle.adfinternal.controller.state.RootViewPortContextImpl.redirect(RootViewPortContextImpl.java:163)
      4. oracle.adfinternal.controller.application.AdfcExceptionHandler.doExceptionHandling(AdfcExceptionHandler.java:196)
      5. oracle.adfinternal.controller.application.AdfcExceptionHandler.handleException(AdfcExceptionHandler.java:97)
      5 frames
    9. oracle.adfinternal.view
      LifecycleImpl.execute
      1. oracle.adfinternal.view.faces.context.RichExceptionHandler._invokeAdfExceptionHandlers(RichExceptionHandler.java:202)
      2. oracle.adfinternal.view.faces.context.RichExceptionHandler._handleUnexpectedException(RichExceptionHandler.java:178)
      3. oracle.adfinternal.view.faces.context.RichExceptionHandler._handleException(RichExceptionHandler.java:128)
      4. oracle.adfinternal.view.faces.context.RichExceptionHandler._handleNextEvent(RichExceptionHandler.java:113)
      5. oracle.adfinternal.view.faces.context.RichExceptionHandler.handle(RichExceptionHandler.java:98)
      6. oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:233)
      6 frames
    10. JavaEE 7
      FacesServlet.service
      1. javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      1 frame
    11. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
      2. weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
      3. weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
      4. weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
      5. weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
      6. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      6 frames
    12. oracle.help.web
      OHWFilter.doFilter
      1. oracle.help.web.rich.OHWFilter.doFilter(OHWFilter.java:197)
      1 frame
    13. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      1 frame
    14. oracle.adf.model
      ADFBindingFilter.doFilter
      1. oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:192)
      1 frame
    15. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      1 frame
    16. oracle.adfinternal.view
      RegistrationFilter.doFilter
      1. oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:105)
      1 frame
    17. org.apache.myfaces
      TrinidadFilterImpl$FilterListChain.doFilter
      1. org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:502)
      1 frame
    18. oracle.adfinternal.view
      AdsFilter.doFilter
      1. oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
      1 frame
    19. org.apache.myfaces
      TrinidadFilterImpl.doFilter
      1. org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:502)
      2. org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:327)
      3. org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:229)
      3 frames
    20. Apache MyFaces Trinidad API
      TrinidadFilter.doFilter
      1. org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
      1 frame
    21. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      1 frame
    22. oracle.adf.library
      LibraryFilter.doFilter
      1. oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:202)
      1 frame
    23. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      1 frame
    24. oracle.security.jps
      JpsAbsFilter$1.run
      1. oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:137)
      1 frame
    25. Java RT
      AccessController.doPrivileged
      1. java.security.AccessController.doPrivileged(Native Method)
      1 frame
    26. oracle.security.jps
      JpsFilter.doFilter
      1. oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
      2. oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
      3. oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:120)
      4. oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:217)
      5. oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:81)
      5 frames
    27. Atmosphere weblogic
      FilterChainImpl.doFilter
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      1 frame
    28. oracle.dms.servlet
      DMSServletFilter.doFilter
      1. oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:220)
      1 frame
    29. Atmosphere weblogic
      WebAppServletContext$ServletInvocationAction.run
      1. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      2. weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      3. weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      4. weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3436)
      5. weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
      5 frames
    30. weblogic.security.acl
      AuthenticatedSubject.doAs
      1. weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      1 frame
    31. weblogic.security.service
      SecurityManager.runAs
      1. weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      1 frame
    32. weblogic.servlet.provider
      WlsSubjectHandle.run
      1. weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      1 frame
    33. Atmosphere weblogic
      ServletRequestImpl.run
      1. weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
      2. weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
      3. weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      4. weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
      4 frames
    34. weblogic.servlet.provider
      ContainerSupportProviderImpl$WlsRequestExecutor.run
      1. weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
      1 frame
    35. weblogic.work
      ExecuteThread.run
      1. weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
      2. weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
      2 frames