-
Notifications
You must be signed in to change notification settings - Fork 754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot call reset() after response has been committed #1566
Comments
Please provide a simple small maven/jetty app. |
Well, since I only see this error in the production logs, I don't think I can create a simple reproducer :-( Isn't my analysis regarding the Mojarra workaround helpful at all? |
I can't do any bugfix without an example to replicate it, so therefor it's only partial helpful ;) |
Hmm, managed to reproduce it quickly before the end of the program. dataModel = new LazyDataModel<User>() {
@Override
public List<User> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
if (first > 0) {
throw new RuntimeException("Test");
}
// initialize result...
return result;
} |
As i said, please provide a full working sample application with maven and jetty |
I've taken the lazy datatable showcase and I've modified LazyCarDataModel, adding
at the beginning of the The result in Jetty when going to the next page (http://localhost:8080/showcase/ui/data/datatable/lazy.xhtml):
|
Did you try to set javax.faces.FACELETS_BUFFER_SIZE as mentioned in the userguide? |
Seems I missed that part. I've setup a breakpoint in
|
I would try something like 100.000 to see if if it will be fixed ;) |
I just did, didn't fix it :( I've setup a breakpoint to see how the response gets marked as committed.
|
The workaround was introduced because: #823 Maybe you could check if mojarra changed something in their responseWriter? |
Maybe we could just remove #endDocument but leave the other 2 #end calls to fix both issues? |
Eh, I've added a comment to the commit, suggesting a ticket for Mojarra, but it was ignored 2d263ef2d17db2188a1964a729b54f906c6de89f0 Should I ask for a full working sample application with maven to reproduce #823? :-D |
i don't have a example as it was fixed by cagatay :P |
I'll try sometime later today to see if I can reproduce #823 without the hack and see if removing endDocument helps. |
I was thinking that since you have my reproducer, you could try to use that to reproduce #823 :-D |
:D i don't have time, sorry |
Can you ask cagatay? It's his regression :-/ |
I could ping him but he is likely very busy.
|
Got it, thanks for your help. |
Hmm, seems this is "caused" by https://java.net/jira/browse/JAVASERVERFACES-3647, starting from 2.2.10 |
Seems the workaround is really needed there, and I even found one more case where that has to be called. |
AFAICS endDocument is only called that mojarra resets the internal FastStringWriter? |
From my memory, as I don't have the code in my face, it's also calling the wrapped writers endDocument and one of them (I think |
Please give it a try ;) |
Will do, but on Monday, when I'll get back at the office. |
Uf, still doesn't work :( This is where
Calling
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><changes><update id="exceptionDialog"><![CDATA[<div id="exceptionDialog"
class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-hidden-container"><div class
="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top"><span id="exceptionDialog_title"
class="ui-dialog-title">An error has occured!</span><a href="#" class="ui-dialog-titlebar-icon ui-dialog-titlebar-close
ui-corner-all" aria-label="Close"><span class="ui-icon ui-icon-closethick"></span></a></div><div class
="ui-dialog-content ui-widget-content">
Message: Test <br />
Type: java.lang.RuntimeException <br /></div></div><script id="exceptionDialog_s" type="text/javascript"
>$(function(){PrimeFaces.cw("Dialog","exceptionDialogWV",{id:"exceptionDialog",width:"500",height:"100"
});});</script>]]></update><eval><![CDATA[var hf=function(type,message,timestampp){PF('exceptionDialogWV'
).show()};hf.call(this,"java.lang.RuntimeException","Test","2016-09-12 14:16:37");]]></eval></changes
></changes></partial-response> |
So I don't see how to make it ignore that |
Hmpf? I thought the problem was the endDocument call? If not, then our other workaround is completely unrelated to this issue? |
Well, the problem with |
Found a workaround: writer.startError("");
writer.endError(); Before I think |
done, please test ;) |
Seems to work now, the response received by the browser is fine now :) <?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><changes><update id="siteAccessRequestsTable"><![CDATA[]]>]]></insert>]]></update></changes><error><error-name></error-name><error-message><![CDATA[]]></error-message></error></changes></partial-response> Doesn't seem correct, but since the response will be reset, not sure if it actually matters. |
Thats not the response which is received by the browser? where do you got this from? |
Well, after the workaround is applied, by calling the various |
So, any interest in fixing the response in the buffer that will be reset? |
I don't think that we can fix for every case. We could do it if we would completely develop our own ResponseWriter etc. |
Yes, I also don't think it matters what happens to the throwaway response. |
I always depends on what you set as BUFFER_SIZE. If the BUFFER_SIZE is to small, the response could be broken anyway. Setting the buffer to big means that you loss a little bit performance. |
So, can this issue be closed? :-) |
I could also only ping @mertsincan, so lets see if he will his mails ;) |
@mertsincan Will you please merge this for 6.0.5? |
I'm sorry for the late reply. I was on holiday :) I'll add it into 6.0.5. |
Excuse me, but can you clarify if the workaround to close invalid partial output due to open tags (PrimeExceptionHandler.handleAjaxException) is expected to work for all cases? Why does it perform this specific sequence of actions?: (I'm using primefaces 6.2, mojarra 2.2.14) writer.endCDATA();
writer.endInsert();
writer.endUpdate();
writer.startError("");
writer.endError();
writer.getWrapped().endElement("changes");
writer.getWrapped().endElement("partial-response"); This breaks the partial response in my case, which doesn't allow an ajax error dialog on the client side to open up, as chrome breaks with a javascript error: "Request return with error:parsererror." <?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><changes><eval><![CDATA[if(window.PrimeFaces){PrimeFaces.ajax.Utils.loadScripts(['/dtax/javax.faces.resource/tree.js.jsf?ln=oam.custom.tree2.javascript','/dtax/javax.faces.resource/cookielib.js.jsf?ln=oam.custom.tree2.javascript']);}]]></eval><eval><![CDATA[if(window.PrimeFaces){PrimeFaces.ajax.Utils.loadScripts(['/dtax/javax.faces.resource/tree.js.jsf?ln=oam.custom.tree2.javascript','/dtax/javax.faces.resource/cookielib.js.jsf?ln=oam.custom.tree2.javascript']);}]]></eval><update id="mainForm:cityMappingGrid"><![CDATA[<table id="mainForm:cityMappingGrid" class="centered" style="text-align: left">
<tbody>
<tr>
<td>State: </td>
<td>AE: </td>
</tr>
<tr>
<td>Map By: </td>
<td><select id="mainForm:selectMapBy" name="mainForm:selectMapBy" size="1" onchange="PrimeFaces.ab({s:this,e:"valueChange",p:"mainForm",u:"mainForm:cityMappingGrid mainForm:commandButtonsGrid",onco:function(xhr,status,args){clearFields();}});"> <option value="NONE">-- Select --</option>
<option value="both" selected="selected">City/County</option>
<option value="city">City</option>
</select></td>
</tr>
<tr>
<td>County: </td>
<td><select id="mainForm:selectCounty" name="mainForm:selectCounty">]]>]]></insert>]]></update></changes><error><error-name></error-name><error-message><![CDATA[]]></error-message></error></changes></partial-response><?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><changes><update id="exceptionDialog"><![CDATA[<div id="exceptionDialog" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow ui-hidden-container"><div class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top"><span id="exceptionDialog_title" class="ui-dialog-title">Exception during ajax request: java.lang.NullPointerException occured</span><a href="#" class="ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all" aria-label="Close"><span class="ui-icon ui-icon-closethick"></span></a></div><div class="ui-dialog-content ui-widget-content"><span class="warning">An unexpected processing error has occurred.
Message: <br />
StackTrace: java.lang.NullPointerException<br/> at [...STACKTRACE EDITED]</div></div><script id="exceptionDialog_s" type="text/javascript">PrimeFaces.cw("Dialog","exceptionDialog",{id:"exceptionDialog",width:"650px",height:"500px"});</script>]]></update><eval><![CDATA[var hf=function(type,message,timestampp){PF('exceptionDialog').show();};hf.call(this,"java.lang.NullPointerException","null","2018-07-10 00:41:18");]]></eval></changes></partial-response> Notice in the response that the sequence name="mainForm:selectCounty">]]>]]></ insert>]]></ update></ changes> is malformed, as there are too many cdata end sections, a non existent insert start tag, and a duplicate </ changes> end tag. If this is a known issue, are there known workarounds you can suggest? Thanks |
Same problem with Primefaces 6.1 (using jsf-undertow-spring-boot-starter 2.4.1). Upgraded JSF from org.glassfish from 2.2.14 to 2.2.18 without success. Tried to switch back to Tomcat without success too. Two partial-response elements are written. Here is my stack in the PrimeExceptionHandler :
I would be glad if you could let me know if there is a compatibility problem with Spring Boot or if someone else has the same problem. Note : I had the same problem with FullAjaxExceptionHandler of Omnifaces. |
See: https://stackoverflow.com/questions/5893460/problems-with-redirect-after-catching-exception (little bit different case but probably the same root cause ;)) |
If this doesn't help, and everything mentioned in the ticket, you can still try myfaces. |
Thanks for your responses and suggestions. I had already tried to change jsf.facelets-buffer-size in my application.yml. I increased it from 100K to 1MB as suggested by BalusC in the response, but without any effect. (I have increase it even to 10 MB) I tried to switch to myfaces, but it is not compatible with the application (even the login page becomes very badly rendered with el not evaluated). With Primefaces 5.0 error pages declared via ErrorPageRegistrar are not taken into account, so there is a NullPointerException in PrimeExceptionHandler. I try again with Primefaces 5.0 with an extended PrimeExceptionHandlerFactory and PrimeExceptionHandler to force an error page, but I have the same problem as with Primefaces 6.1 with two partial-response :
Perhaps interesting to investigate this problem I have a NoSuchElementException in java EL : So previous partial response is broken during the JSF render phase. We can see that form element is never closed as some p:inputText elements cannot be rendered. I am wondering if JSF writer is not in a bad state after that and its buffer could not be reset properly. |
Hi,
I'm seeing a worrying number of exceptions regarding
PrimeExceptionHandler
trying to reset the response after it was commited when handling Ajax exceptions.As far as I see, it checks if the response is committed (at
primefaces/src/main/java/org/primefaces/application/exceptionhandler/PrimeExceptionHandler.java
Line 147 in da76a54
writer
methods (includingendDocument()
, which seems to flush the response writer).Using PF 6.0 with Mojarra 2.2.13 on Tomcat 8.0.36
The text was updated successfully, but these errors were encountered: