As mentioned in the manual, @Redirect and @Render don't work for certain phases of the JSF lifecycle. WHich are you using?
I was using @Render, I'll try using @Redirect instead. I'm guessing @Render would've been preferrable so that the error appears on the same page rather than (like a FacesMessage from an invalid field)
Why do @Render (only in INVOKE_APPLICATION) and @Redirect (not in RENDER_RESPONSE) not work at any time in the request lifecycle? Can't redirects and forwards happen at any time? (I'm sure there's a good reason, maybe someone could explain.)
Nope, as soon as you do something to the servlet response object, you can't change your mind later and do something else.
However, I don't quite recall why I decided that you couldn't use @Render during the PROCESS_VALIDATIONS and UPDATE_MODEL_VALUES phases. There was probably some reason why this didn't work, but its possibly an oversight. Perhaps you want to experiment with the changing the Seam code and see if I got this wrong....
Changing exceptions.xml to redirect from render doesn't do anything - same problem. This exception is getting caught somewhere and not propagating to a point where exceptions.xml can do anything with it.
What am I supposed to do here? (Short of creating an action method - see my OP.)
In the log, the OptimisticLockException (OLE) shows up somewhere between the following two statements:
[SeamPhaseListener] after phase: INVOKE_APPLICATION(5) #Several other statements here #The exception stack traces followed immediately by the next line: [SeamPhaseListener] before phase: RENDER_RESPONSE(6)
Also, the OLE is caused by a org.hibernate.StaleObjectStateException. The OLE causes org.jboss.tm.JBossRollbackException which then causes java.lang.IllegalStateException. I try catching all of them in exceptions.xml, but none of them work!
<exceptions> <exception class="org.hibernate.StaleObjectStateException"> <redirect>optimistic lock exception</redirect> </exception> </exceptions>
Is my only option then to use an action method? It seems like an ugly solution but the only thing I can think of...am I missing any possibilities?
In cases like this where an OptimisticLockException occurs, does Seam have no way of using exceptions.xml to handle this fact and display a nice error message?
I've exhausted all my resources and don't know where else to turn apart from this board...please, if somebody knows how to use exceptions.xml to catch it, let me know...
If you need any more info on the issue, I can provide it...
Nope, Seam cant do much about exceptions which occur at this point. As I've said here many times, JSF exception handling sucks ass, your only option is to beg for proprietary features from the JSF implementations.
If you read the JSF spec, it actually says explicitly that JSF implementations should swallow and ignore exceptions that occur in phase listeners.
Actually, that's not quite right. There probably is something we can do to allow these exceptions to be handled in exceptions.xml. Will be messy, but possible.