Exception handling Seam 2.3 (JBoss 7)
joshd Jan 23, 2013 6:30 AMI try to understand the exception handling behavior - without success so far..
I have to browsers open (Safari and Firefox) and load the entity detail form for the same entity in both browsers. This edit form starts a LRC. Then I submit the first form (dao.merge()) and then the second. Of course that fails because of optimistic locking (@Version annotation on the "int version" attribute of entity). Now of course at least I want the user to be informed about that. The according exception handler in the pages.xml is present,
{code} <exception class="javax.persistence.OptimisticLockException">
<end-conversation/>
<redirect view-id="/error.xhtml">
<message severity="error">Error message..</message>
</redirect>
</exception>
<exception>
<redirect view-id="/error.xhtml">
<message severity="error">Unexprected error, please try again</message>
</redirect>
</exception>
{code}
Case 1: works
I have a
{code:xml}<p:ajax event="blur" update="nameEdit" partialSubmit="true"/>{code}
on the name-field of the entity. So - after I've submitted the first form - when I change the name here I get the expected javax.persistence.OptimisticLockException (as first in trace) onBlur, the exception-handler matched, I see the error.xhtml - everthing ok.
Case 2: doesnt work
I remove the validation ajax-onblur-event. After submitting form no. 1 changing the name field in form no. 2 und press
{code:xml}<p:commandButton
id="update"
action="#{entityAction.save}"
value="#{messages['base.action.save']}"
icon="ui-icon-check"
update=":mainform" />
{code}
The first exception in console is a javax.ejb.EJBTransactionRolledbackException (first causedBy OptimisticLock, second causedBy StaleObject). But no exception handler at all is stepping in. And then the application is not reacting on ajax calls anymore (APPLICATION ERROR: transaction still active in request with status 0).
Can anybody help me with whats wrong here?