0
votes

Version :

Apache MyFaces 2.1.14 and RichFaces 4.3.5

Issue:

We are migrating from jsf 1.2 to jsf 2. We are facing very strange issue as :

When any ajax operation is performed , we are getting below error and page is not refreshed (or rerended as usual)

org.apache.myfaces.context.servlet.ServletExternalContextImpl setResponseContentType
SEVERE: Cannot set content type. Response already committed

This question is very similar to jsf 2.0 response already commented (ajax) , but it seems that no one has answered this question. It also comes only at the specific page and same code at other places works fine and this error is very random in nature?

Is this anything to do with apache myfaces ? Please help if any inputs are available .

The xhtml ajax tags causing these issues are : a4j:commandLink and a4j:ajax

1
Is there any stacktrace that you can show ? Normally there should be another error in your code (during the ajax call), - Laabidi Raissi

1 Answers

2
votes

That usually occurs because there is an error on render response phase and part of the response has been already send to the client. The algorithm then try to render the error page but it can't because the response has been already sent so you get the problem.

The solution usually is avoid the early commit, increasing the buffer size of the response. To do that use javax.faces.FACELETS_BUFFER_SIZE web config parameter (by default is 1024 bytes).

Theoretically this param has a negative effect over memory, because the larger the buffer, the more memory is allocated for that, but the JVM is fast enough if there is enough memory.