[
https://issues.jboss.org/browse/JBSEAM-4968?page=com.atlassian.jira.plugi...
]
Vaclav Dedik edited comment on JBSEAM-4968 at 8/8/12 7:32 AM:
--------------------------------------------------------------
This looks like a Seam bug. The exception ViewExpiredException is not properly handled
because the response is already committed when the Seam exception handler attempts to
redirect to /home.xhtml. That's because before the ViewExpiredException is thrown, the
request is intercepted by Seam security and since main.xhtml is
login-required="true" (and the user is no longer logged in), Seam sends redirect
to home.xhtml and commits the response. In other words, two concurrent invocations of
HttpServletResponse#sendRedirect take place, which causes IllegalStateException being
thrown.
If you change this piece of code:
{code:title=/WEB-INF/pages.xml|borderStyle=solid}
...
<page view-id="/main.xhtml" login-required="true">
<navigation from-action="#{hotelBooking.selectHotel(hot)}">
<redirect view-id="/hotel.xhtml"/>
</navigation>
<navigation from-action="#{bookingList.cancel}">
<redirect/>
</navigation>
</page>
...
{code}
to this:
{code:title=/WEB-INF/pages.xml|borderStyle=solid}
...
<page view-id="/main.xhtml">
<navigation from-action="#{hotelBooking.selectHotel(hot)}">
<redirect view-id="/hotel.xhtml"/>
</navigation>
<navigation from-action="#{bookingList.cancel}">
<redirect/>
</navigation>
</page>
...
{code}
This problem no longer occurs.
To fix this problem entirely, some minor change in Seam source code is required.
This is what I could come up with:
{code:title=src/main/java/org/jboss/seam/web/RedirectFilter.java|borderStyle=solid}
Index: src/main/java/org/jboss/seam/web/RedirectFilter.java
===================================================================
--- src/main/java/org/jboss/seam/web/RedirectFilter.java (revision 15015)
+++ src/main/java/org/jboss/seam/web/RedirectFilter.java (working copy)
@@ -69,7 +69,9 @@
}
}
}
- super.sendRedirect(url);
+ if ( !super.getResponse().isCommitted() ) {
+ super.sendRedirect(url);
+ }
}
};
}
{code}
was (Author: vdedik):
This looks like a Seam bug. The exception ViewExpiredException is not properly handled
because the response is already committed when the Seam exception handler attempts to
redirect to /home.xhtml. That's because before the ViewExpiredException is thrown, the
request is intercepted by Seam security and since main.xhtml is
login-required="true", Seam sends redirect to home.xhtml and commits the
response. In other words, two concurrent invocations of HttpServletResponse#sendRedirect
take place, which causes IllegalStateException being thrown.
If you change this piece of code:
{code:title=/WEB-INF/pages.xml|borderStyle=solid}
...
<page view-id="/main.xhtml" login-required="true">
<navigation from-action="#{hotelBooking.selectHotel(hot)}">
<redirect view-id="/hotel.xhtml"/>
</navigation>
<navigation from-action="#{bookingList.cancel}">
<redirect/>
</navigation>
</page>
...
{code}
to this:
{code:title=/WEB-INF/pages.xml|borderStyle=solid}
...
<page view-id="/main.xhtml">
<navigation from-action="#{hotelBooking.selectHotel(hot)}">
<redirect view-id="/hotel.xhtml"/>
</navigation>
<navigation from-action="#{bookingList.cancel}">
<redirect/>
</navigation>
</page>
...
{code}
This problem no longer occurs.
To fix this problem entirely, some minor change in Seam source code is required.
This is what I could come up with:
{code:title=src/main/java/org/jboss/seam/web/RedirectFilter.java|borderStyle=solid}
Index: src/main/java/org/jboss/seam/web/RedirectFilter.java
===================================================================
--- src/main/java/org/jboss/seam/web/RedirectFilter.java (revision 15015)
+++ src/main/java/org/jboss/seam/web/RedirectFilter.java (working copy)
@@ -69,7 +69,9 @@
}
}
}
- super.sendRedirect(url);
+ if ( !super.getResponse().isCommitted() ) {
+ super.sendRedirect(url);
+ }
}
};
}
{code}
metawidget example, error handling ViewExpiredException
"Exception when handling error trying to reset the response.:
javax.faces.application.ViewExpiredException"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: JBSEAM-4968
URL:
https://issues.jboss.org/browse/JBSEAM-4968
Project: Seam 2
Issue Type: Bug
Components: Core
Affects Versions: 2.3.0.BETA2
Environment: AS 7.1.2.Final, 2.3.0.CR1-SNAPSHOT
Reporter: Marek Schmidt
Assignee: Marek Novotny
Labels: metawidget/booking
Fix For: 2.3.0.CR1
{noformat}
16:44:34,252 INFO [javax.enterprise.resource.webcontainer.jsf.context]
(http-/127.0.0.1:8080-2) Exception when handling error trying to reset the response.:
javax.faces.application.ViewExpiredException: [23/1938]
ain.seam - View /main.seam could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:205)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
[jsf-impl-2.1.7-jbossorg-2.jar:]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
[jboss-jsf-api_2.1_spec-2.0.2.Final.jar:2.0.2.Final]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.16.Final.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.16.Final.jar:]
at
org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
[jboss-as-jpa-7.1.2.Final.jar:7.1.2.Final]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.2.Final.jar:7.1.2.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.16.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.16.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.16.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
[jbossweb-7.0.16.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
[jbossweb-7.0.16.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]
16:44:34,267 ERROR
[org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/seam-metawidget-booking].[Faces
Servlet]] (http-/127.0.0.1:8080-2) Servlet.service() for servlet Faces Servlet threw
exceptio
n: java.lang.IllegalStateException
at
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:437)
[jbossweb-7.0.16.Final.jar:]
at
javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:170)
[jboss-servlet-api_3.0_spec-1.0.1.Final.jar:1.0.1.Final]
at org.jboss.seam.web.RedirectFilter$1.sendRedirect(RedirectFilter.java:72)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.mock.MockExternalContext.redirect(MockExternalContext.java:528)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.faces.FacesManager.redirect(FacesManager.java:220)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.faces.FacesManager.redirect(FacesManager.java:185)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.faces.Navigator.redirect(Navigator.java:56)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.faces.Navigator.redirect(Navigator.java:43)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.exception.RedirectHandler.handle(RedirectHandler.java:51)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.exception.Exceptions.handle(Exceptions.java:76)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at
org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:114)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
[jboss-seam.jar:2.3.0.CR1-SNAPSHOT]
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.16.Final.jar:]
at
org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
[jboss-as-jpa-7.1.2.Final.jar:7.1.2.Final]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
[jboss-as-web-7.1.2.Final.jar:7.1.2.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.16.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.16.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
[jbossweb-7.0.16.Final.jar:]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.16.Final.jar:]
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679)
[jbossweb-7.0.16.Final.jar:]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931)
[jbossweb-7.0.16.Final.jar:]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira