wood burning stoves*
The moose likes JSF and the fly likes IllegalStateException: Cannot forward. Response already committed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "IllegalStateException: Cannot forward. Response already committed." Watch "IllegalStateException: Cannot forward. Response already committed." New topic
Author

IllegalStateException: Cannot forward. Response already committed.

Sachin Vrma
Greenhorn

Joined: Jan 19, 2007
Posts: 7
hi

i am using WebSphere Application Server V6.

On a command button i am invoking a method whitch is returning a string.
based on navigation rule navigation takes place BUT
i am getting java.lang.IllegalStateException: Cannot forward. Response already committed.
even after this Exception the next page comes and the application is working.

the same code is working on Exadel Studio 4.0 with apache tomcat

Please tell me when and why this Exception occures and how can we overcome this.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Post your code
Sachin Vrma
Greenhorn

Joined: Jan 19, 2007
Posts: 7
Hi Ali,

i have also made a test app just to check wheather it working or not.
In this test App :

Page1.jsp
<HTML>
<HEAD>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<TITLE>Page1.jsp</TITLE>
</HEAD>
<f:view>
<BODY>
<h:form>
<P>page 1</P>
<h:commandButton value="go" action="#{pc_Page1.go}" ></h:commandButton>
</h:form>
</BODY>
</f:view>
</HTML>

Page2.jsp
just written page2 int this page.

In BackingBean
just a single fuction:
public String go()
{
return "page2";
}


In faces Config; the navigation rule is:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>page2</from-outcome>
<to-view-id>Page2.jsp</to-view-id>
</navigation-case>
</navigation-rule>


I am using IBM's WebSphere Integration Developer(WID) v6.
Here i have used sun's implementation of JSF.
I just copied the jars to lib folder. Then i got a massage that a new version is added and need to download extra tag libs from sun's site.

i think i am missing any tag lib.
but in that case it should not work.
but even after getting the exception the next page comes.
[ January 22, 2007: Message edited by: Sachin Vrma ]
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
try changing page2.jsp to

<HTML>
<HEAD>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<TITLE>Page2.jsp</TITLE>
</HEAD>
<f:view>
<body>
<P>page 2</P>
</h:form>
</body>
</f:view>
</HTML>


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Sachin Vrma
Greenhorn

Joined: Jan 19, 2007
Posts: 7
yes the Page2.jsp is also a jsf and written in the same manner.
providing the stack here:
Please check it out....


[1/23/07 15:08:46:943 IST] 0000007f ServletWrappe E SRVE0068E: Could not invoke the service() method on servlet Faces Servlet. Exception thrown : java.lang.IllegalStateException: Cannot forward. Response already committed.
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:157)
at com.ibm.faces.context.MultipartExternalContextImpl.dispatch(MultipartExternalContextImpl.java:320)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:254)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java(Compiled Code))
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[1/23/07 15:08:47:022 IST] 0000007f ServletWrappe E SRVE0014E: Uncaught service() exception root cause Faces Servlet: Cannot forward. Response already committed.
[1/23/07 15:08:47:147 IST] 0000007f LocalTranCoor E WLTC0017E: Resources rolled back due to setRollbackOnly() being called.
[1/23/07 15:08:47:194 IST] 0000007f WebApp E SRVE0026E: [Servlet Error]-[Faces Servlet]: java.lang.IllegalStateException: Cannot forward. Response already committed.
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:157)
at com.ibm.faces.context.MultipartExternalContextImpl.dispatch(MultipartExternalContextImpl.java:320)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:254)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java(Compiled Code))
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java(Compiled Code))
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:101)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

[1/23/07 15:08:47:225 IST] 0000007f SRTServletRes W WARNING: Cannot set status. Response already committed.
[1/23/07 15:08:47:287 IST] 0000007f SRTServletRes W WARNING: Cannot set header. Response already committed.
[ January 23, 2007: Message edited by: Sachin Vrma ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalStateException: Cannot forward. Response already committed.