[#JAVASERVERFACES-2277] long html code output in server: java

advertisement
[JAVASERVERFACES-2277] long html code output in server:
java.lang.IllegalStateException: PWC3999: Cannot create a session after the
response has been committed Created: 02/Jan/12 Updated: 06/Jan/13 Resolved: 16/Mar/12
Status:
Project:
Component/s:
Affects
Version/s:
Fix Version/s:
Closed
javaserverfaces
facelets, renderkit
2.0, 2.1
Type:
Reporter:
Resolution:
Labels:
Remaining
Estimate:
Time Spent:
Original
Estimate:
Environment:
Bug
montblack
Fixed
None
Not Specified
Attachments:
Issue Links:
Tags:
Description
2.1.8, 2.2.0-m02
Priority:
Assignee:
Votes:
Major
Manfred Riem
1
Not Specified
Not Specified
glassfish 3.1.1, jsf 2.0 or 2.1 netbeans 7.1rc2, windows vista
changebundle-test.txt
Duplicate
is
duplicated
by
is
duplicated
by
is
duplicated
by
Related
is related
to
changebundle.txt
JAVASERVERFACES- State saving broken on Tomcat Closed
2031
JAVASERVERFACES- java.lang.IllegalStateException: Closed
2215
Cann...
JAVASERVERFACES- Flash incompatible with HTTP Closed
2332
Chunking
JAVASERVERFACES- View cannot be restored with
2143
Cookies off
glassfish-3-1-1, html, jsf
Closed
i start a project, i onle have html code 2 pages, a template and a index both xhtml.(download:
http://freimanautos.com/bug/Aceites.rar)
when in the file resources/template/prime/masterpage.xhtml i uncoment the line 90:
<!-->
the server output:
GRAVE: Error Rendering View[/index.xhtml]
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been
committed
i try with many diferents html templay made with artisteer, and whe the template its very long
the server crash and it dont show the rest of the components
why?
Comments
Comment by Manfred Riem [ 03/Jan/12 ]
Using the attached application I am observing the same behavior. The ServerSideStateHelper is trying to
acquire a session, but since the response has already been written it is not allowed to do so. For server-side
state saving we need to make sure we get the session before we start writing the response so the server-side
state saving has a valid session.
Workaround: make sure you establish a session before hitting this page.
Comment by montblack [ 03/Jan/12 ]
but it's my index page and only had error when i add more html code if i dont have many html code it works
fine and i try with 2 diferent html templates, could you tell me where i must establish the seasson?
and sorry for my english i speak spanish
Comment by frederickkaempfer [ 03/Jan/12 ]
You can also try to increase the response buffer size to a larger value in your web.xml, for example:
<context-param>
<param-name>com.sun.faces.responseBufferSize</param-name>
<param-value>100000</param-value>
</context-param>
Comment by Manfred Riem [ 03/Jan/12 ]
Create a simple index.jsp where you create a session and then use it to redirect to the Facelet page.
Comment by montblack [ 04/Jan/12 ]
<context-param>
<param-name>com.sun.faces.responseBufferSize</param-name>
<param-value>100000</param-value>
</context-param>
doesn't work
create a index.jsp work for de index page but if got a email with a link to a page that is not the index, then
desn't work.
Comment by Manfred Riem [ 04/Jan/12 ]
Ed, I have attached a changebundle (for 2.1_X) that contains the fix
Comment by Ed Burns [ 11/Jan/12 ]
Because a workaround exists, downgrading this from blocker.
Comment by Ed Burns [ 12/Jan/12 ]
Re-assigning to Manfred.
When I applied your patch, I observed that com.sun.faces.render.OutputScriptStyleTestCase
started failing.
Upon investigation I learned that your change made it so what used to render as this
<link type="text/css" rel="stylesheet" href="/jsf-systest/faces/javax.faces.resource/case9.css"/>
Now rendered as this
<link type="text/css" rel="stylesheet" href="/jsfsystest/faces/javax.faces.resource/case9.css;jsessionid=399d86b3d2c310692a519705ddee"/>
We all agree that this is not the desired behavior.
Comment by Manfred Riem [ 12/Jan/12 ]
Unfortunately this behavior comes to play in how Glassfish does an encodeResourceUrl when the session
has just been created (isNew is true). The Resource gets its URL from calling
HttpServletResponse.encodeResourceUrl. By default Glassfish seems to have both URL rewriting and
cookie handling enabled for a new session.
If JSF resources would not require a session we could use the URL directly instead of pushing it through
encodeResourceUrl. Otherwise we are stuck with the behavior of the container at hand.
Comment by Manfred Riem [ 14/Mar/12 ]
Linking this issue as it is the same issue
Comment by Manfred Riem [ 14/Mar/12 ]
Acquire the session early if it server-side state saving is used and the viewroot is NOT flagged transient.
Comment by Manfred Riem [ 14/Mar/12 ]
Applied to 2.1.x branch
svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2277, r=rogerk, Acquire the
session early if it server-side state saving is used and the viewroot is NOT flagged transient." jsfri\src\main\java\com\sun\faces\application\view\FaceletViewHandlingStrategy.java
Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletViewHandlingStrategy.java
Transmitting file data .
Committed revision 9765.
Comment by Ed Burns [ 15/Mar/12 ]
Hello Manfred, thanks for committing this, but I'm seeing test breakages as a result of this commit. What is
your plan for fixing them? For example:
[junit] junit.framework.AssertionFailedError
[junit] at
com.sun.faces.render.OutputScriptStyleTestCase.testOutputScriptStyle(OutputScriptStyleTestCase.java:143)
[junit] at com.sun.faces.htmlunit.HtmlUnitFacesTestCase.runTest(HtmlUnitFacesTest
This assertion is:
assertTrue(text.matches(
"(?s).<head>."+
"<link.* type=\"text/css\".rel=\"stylesheet\". href=\"/jsf-systest/faces/javax.faces.resource/case9.css\"
s*/>.*" +
"</head>.*"
));
And the relevant text in the response is:
<link type="text/css" rel="stylesheet" href="/jsfsystest/faces/javax.faces.resource/case9.css;jsessionid=651b2b2172978f77d6db8bf500c2"/>
You must fix all such occurrences. I had hoped this would have been done atomically with the commit, but
at any rate, it must be done.
Comment by Manfred Riem [ 15/Mar/12 ]
I tested it twice locally before committing this and it passed on my machine
Comment by Manfred Riem [ 15/Mar/12 ]
Fixes for broken tests
Comment by Manfred Riem [ 15/Mar/12 ]
Applied to 2.1.x branch, fixes for broken tests
svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2277, fixes broken tests"
Sending jsf-ri\systest\src\com\sun\faces\render\OutputScriptStyleTestCase.java
Sending jsf-ri\systest-per-webapp\request-char-encoding-nosession\src\java\com\sun\faces\systest\NoSessionCharEncTestCase.java
Transmitting file data ..
Committed revision 9767.
Comment by Manfred Riem [ 16/Mar/12 ]
Applied to 2.2.x (trunk)
svn commit -m "Fixes http://java.net/jira/browse/JAVASERVERFACES-2277, r=rogerk" jsfri\src\main\java\com\sun\faces\application\view\FaceletViewHandlingStrategy.java jsf-ri\systest\src jsfri\systest-per-webapp
Sending jsf-ri\src\main\java\com\sun\faces\application\view\FaceletViewHandlingStrategy.java
Sending jsf-ri\systest\src\com\sun\faces\render\OutputScriptStyleTestCase.java
Sending jsf-ri\systest\src\com\sun\faces\systest\RenderKitsTestCase.java
Sending jsf-ri\systest-per-webapp\request-char-encoding-nosession\src\java\com\sun\faces\systest\NoSessionCharEncTestCase.java
Transmitting file data ....
Committed revision 9768.
Comment by Puls [ 18/Mar/12 ]
Hi Manfred, does this fix also fix the flash related problems as reported in ?
Comment by Manfred Riem [ 19/Mar/12 ]
Yes, if I did miss a corner case please file an issue specifically for it. Note the latest 2.1 SNAPSHOT release
should include these fixes, so give it a try and let me know.
Comment by Ed Burns [ 20/Mar/12 ]
Have all the testcases that are broken by this fix been fixed?
Comment by Manfred Riem [ 20/Mar/12 ]
As stated by the commit log attached to the issue you can see that is the case. Then the subsequent commit
log states the entire bundle was applied to trunk.
Comment by Puls [ 21/Mar/12 ]
Hi Manfred, as you suggested I installed the latest 2.1.8 snapshot I found on Glassfish 3.1.2 (Mojarra 2.1.8
(SNAPSHOT 20120321-0021). The main issue that I reported in is not fixed and can still be reproduced
using the attached application. The problem is that the flash cookie is not correctly written when HTTP
chunking is enabled. I bleive the issue should be reopened.
Comment by adrian_e [ 24/Jul/12 ]
I recommend that this be re-opened. It is still a problem in 2.1.8.
Comment by Manfred Riem [ 24/Jul/12 ]
Please create a new issue and attach an application that reproduces the problem.
Comment by harrypham [ 25/Jul/12 ]
If any create an issue please link the new issue. I still have this problem in 2.1.10
Comment by chinboon [ 06/Jan/13 ]
This issue is still occurring for me, i am using 2.1.16.
Generated at Tue Feb 09 15:27:12 UTC 2016 using JIRA 6.2.3#6260sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.
Download