Sometimes, if you click on a link, and then in a very short time, you click on another link without waiting the response from the server, you can get a JSF error.
This can happen very frequently when using Ajax requests as users does not always see that the server did not answer yet, so it can be easier from them to trigger an additional request.
There is no ideal solution to this problem, so it is important to understand why it is happening before picking a solution.
Seam does not handle concurrent requests in the same conversation simultaneously: when a request arrives, if a preceding request is already being processed, it'll wait for the other request to finish before processing the new one. It does not wait indefinitely: it waits for a given, configurable, amount of time. When this timeout is reached, as the first request is still being processed, the corresponding conversation is locked. So the new request is processed in a "temporary" conversation. This temporary conversation does not hold the contextual information that the request may need, and this would lead to an error.
By default, this timeout is configured to 1s, so if this your server is quite slow, you can set up a higher timeout to avoid this issue. Note that it is important not to setup a value too high: concurrent requests may keep piling up on the server, and may slower it even more. To do that, in the deployment-fragment of your own project, add the definition:
At startup, you'll get in nuxeo.ear/nuxeo.war/WEB-INF/components.xml a block like:
If this is not enough, or if this problem is happening on some specific pages, the other options you have are :
- try to optimize the request that takes time: if some request is very slow, users may be tempted to click elsewhere waiting for the server to answer.
- use ajax configurations to handle concurrent requests: ajax makes it possible to put requests in a queue so that similar requests are not sent to the server. It also allows to wait for a given amount of time before sending a request, etc...
- use javascript tricks to make it impossible for the user to click somewhere else (or even to keep on clicking on the costly link) while the server has not answered.