Description of problem: When ViewExpiredException occurs in an Ajax request, the response is malformed, containing duplicate partial-response element. This results in the response not being parsed (and in this case, redirect not being followed). <?xml version='1.0' encoding='UTF-8'?> <partial-response><redirect url="/seam-booking/home.seam?cid=22"></redirect></partial-response><?xml version="1.0" encoding="UTF-8"?> <partial-response><redirect url="/seam-booking/home.seam?cid=22"/></partial-response> Version-Release number of selected component (if applicable): 2.2.0.CR2 How to reproduce: Follow the BackButtonTest procedure Steps to Reproduce: 1. Build booking example from WFK 2.2.0.CR2 distribution and deploy on EAP 6.0.1 2. Navigate to http://localhost:8080/seam-booking/ and login as gavin:foobar 3. Type anything into the Search field 4. Click Logout 5. Click browser's back button 6. Click Find Hotels Actual results: No visual response. An Ajax request is sent in the background and the above mentioned malformed duplicate partial-response XML is returned. Expected results: Either - hitting the back button with the URL staying at /seam-booking/home.seam, or - hitting the back button, getting to /seam-booking/main.seam then clicking "Find Hotels" and getting redirected to /seam-booking/home.seam should result in "Please log in first" appearing under login box.
This seems to happen, because there are two rules for the redirection in pages.xml: - main.xhtml has login required, handled in Pages.redirectToLoginView() <page view-id="/main.xhtml" login-required="true"> - exception handler for ViewExpiredException, handled in ExceptionFilter <exception class="javax.faces.application.ViewExpiredException"> <redirect view-id="/home.xhtml"> ... </exception> None of the Seam's components involved (ExceptionFilter, Pages, Exceptions, RedirectHandler, MockExternalContext, ... ?) checks whether the response has already been written and the redirect partial response gets written twice.
Doc text edited and inserted into the 2.2.0 release notes book. Docs stage URL: https://documentation-devel.engineering.redhat.com/docs/en-US/JBoss_Web_Framework_Kit/2.2/html-single/2.2.0_Release_Notes/index.html Build: JBoss_Web_Framework_Kit-2.2.0_Release_Notes-2.2-en-US-0-26
I forgot to emphasize this, but the issue occurs only when there are _multiple_ causes for the redirect. If _only_ the ViewExpiredException occurs, the response is OK, and the redirect works. The same for the login-required handler -- redirect works when it happens _alone_. Also I made a mistake -- it's the whole XML document that is duplicated in the HTTP response body, not just the partial-response element. Suggested ammendment to the RN text: "When there are multiple causes for a redirect in a single AJAX request, a malformed XML response is returned. Consequently, the affected redirection rules defined in pages.xml file are not correctly processed and therefore not followed. No workaround for this issue is currently known."
Marek Novotny <mnovotny> made a comment on jira JBSEAM-5093 I don't know how to check already written partial-response in response output stream, so I clear the buffer with not committed content and let MockExternalContext.redirect(String url) to add the partial-response data. The tests - ErrorHandlingTest and ExceptionRedirectTest passes and booking demo behaves correctly again. I will commit the change and will try to launch functional tests to confirm it doesn't affect something else.
Marek Novotny <mnovotny> updated the status of jira JBSEAM-5093 to Resolved
Marek Novotny <mnovotny> made a comment on jira JBSEAM-5093 fixed by https://github.com/seam2/jboss-seam/commit/4c250daaa260bd7ccd9c1cf752a7d381b0e13315, if ftests doesn't pass I will reopen the issue again.
wrong bz # in commit's comment references but it is fixed by https://source.jboss.org/changelog/Seam?cs=15494
Marek Novotny <mnovotny> updated the status of jira JBSEAM-5093 to Closed
Marek Novotny <mnovotny> made a comment on jira JBSEAM-5093 2.3.1.CR1 is now out, so closing all resolved issues
Verified on 2.3.0.ER1 release.
Updated doc text.