Bug 952571 - Seam produces malformed partial response on ViewExpiredException with Ajax
Summary: Seam produces malformed partial response on ViewExpiredException with Ajax
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise WFK Platform 2
Classification: Retired
Component: Seam
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ER1
: 2.3.0
Assignee: Marek Novotny
QA Contact: Marek Schmidt
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-04-16 08:42 UTC by Ron Šmeral
Modified: 2016-11-01 01:36 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
The partial-response elements in AJAX responses, produced by Seam, were duplicated. As a consequence, redirection rules defined in the pages.xml file were not processed correctly and therefore not followed. This has been fixed by placing a check in MockExternalContext to ensure that the response is not already committed when writing the partial response stanza. As a result, the duplication does not happen.
Clone Of:
Environment:
Last Closed: 2013-07-16 11:32:35 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat One Jira Issue Tracker JBSEAM-5093 Major Closed Seam produces malformed partial response on ViewExpiredException with Ajax 2018-04-05 09:28:33 UTC

Description Ron Šmeral 2013-04-16 08:42:07 UTC
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.

Comment 1 Ron Šmeral 2013-04-16 11:06:51 UTC
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.

Comment 2 Petr Penicka 2013-04-19 13:31:35 UTC
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

Comment 3 Ron Šmeral 2013-04-19 17:03:13 UTC
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."

Comment 4 JBoss JIRA Server 2013-05-06 18:37:51 UTC
Marek Novotny <mnovotny@redhat.com> 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.

Comment 5 JBoss JIRA Server 2013-05-06 18:39:38 UTC
Marek Novotny <mnovotny@redhat.com> updated the status of jira JBSEAM-5093 to Resolved

Comment 6 JBoss JIRA Server 2013-05-06 18:39:38 UTC
Marek Novotny <mnovotny@redhat.com> 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.

Comment 7 Marek Novotny 2013-05-10 13:50:42 UTC
wrong bz # in commit's comment references but it is fixed by https://source.jboss.org/changelog/Seam?cs=15494

Comment 9 JBoss JIRA Server 2013-06-07 13:54:50 UTC
Marek Novotny <mnovotny@redhat.com> updated the status of jira JBSEAM-5093 to Closed

Comment 10 JBoss JIRA Server 2013-06-07 13:54:50 UTC
Marek Novotny <mnovotny@redhat.com> made a comment on jira JBSEAM-5093

2.3.1.CR1 is now out, so closing all resolved issues

Comment 11 Tomas Remes 2013-06-13 07:20:46 UTC
Verified on 2.3.0.ER1 release.

Comment 12 Sneha 2013-07-03 09:50:32 UTC
Updated doc text.


Note You need to log in before you can comment on or make changes to this bug.