1 Reply Latest reply on Sep 20, 2008 7:02 PM by pmuir

    Exception in JSF render phase usecase

    gjeudy

      Hi,


      I'm calling an EJB from a view in the JSF render response phase. This EJB could throw javax.persistence.PersistenceException. What I want to do now is to redirect and display root cause information (nested exception) in a custom xhtml page.


      The redirecting works fine as per pages.xml config (also disabled seam debug mode and facelets dev mode):


      <exception class="javax.persistence.PersistenceException">
                <redirect view-id="/exception/jdbcException.xhtml">
                     <message severity="error">Database access error occurred.</message>
                </redirect>
           </exception>



      The problem is that the root exception is swallowed(somewhere). The redirect happens on the next transactional db access, it is catching another PersistenceException with the following useless root cause:


      javax.persistence.PersistenceException:
                               org.hibernate.exception.GenericJDBCException: Cannot open connection
      



      further down, root cause shows:


      javax.resource.ResourceException:
                               Transaction is not active: tx=TransactionImple < ac, BasicAction: afac73b:9fc:48cea974:dd status: ActionStatus.ABORTED >
                               



      Does anybody know how I can cleanly display the root cause of my PersistenceException ? I don't understand why initial PersistenceException is swallowed. (it is still logged by hibernate JDBCExceptionReporter though.)


      The DB call is triggered by an EL expression inside an xhtml page during RENDER phase. The EL expression is bound to a

      @Factory

      . The factory method gets called twice both times throwing a PersistenceException. I think Seam calls factory method repeatdly when application code fails to assign a value to outjected factory value.