4 Replies Latest reply on Aug 3, 2009 9:07 AM by Matthias Age

    Transaction rollbacks - how to control them

    Matthias Age Newbie

      Hi,


      Yuan/Heute write in their book JBoss Seam





      By default, the transaction is rolled back only when an unchecked exception occurs.



      But in my case this doesn't seem to work: in a delete action, where the db complains about a constraint violation exception and a unchecked exception is thrown, seam tries to rollback the transaction, but then the following error appears: could not roll back transaction java.util.EmptyStackException.
      Why that? Here's the stack trace.







      Caused by: java.sql.SQLException: ORA-02292: integrity constraint (REVE.EZSE_SETT_FK) violated - child record found
      
           at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
           at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
           at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
           at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
           at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
           at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
           at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
           at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
           at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
           at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2523)
           ... 97 more
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 WARN  [ExceptionFilter] running exception handlers
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [FacesLifecycle] >>> Begin exception recovery
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [Manager] Restoring conversation with id: 30
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [ExceptionFilter] killing transaction
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [UTTransaction] rolling back JTA transaction
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 ERROR [ExceptionFilter] could not roll back transaction
      java.util.EmptyStackException
           at java.util.Stack.peek(Stack.java:85)
           at java.util.Stack.pop(Stack.java:67)
           at org.jboss.seam.transaction.SeSynchronizations.afterTransactionRollback(SeSynchronizations.java:45)
           at org.jboss.seam.transaction.UTTransaction.rollback(UTTransaction.java:70)
           at org.jboss.seam.web.ExceptionFilter.rollbackTransactionIfNecessary(ExceptionFilter.java:159)
           at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:113)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:70)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
           at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
           at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:619)
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [FacesManager] redirecting to: /reve/error.seam?cid=30
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [FacesLifecycle] After render response, destroying contexts
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [FacesLifecycle] <<< End JSF request for /reve/ReveSettoriEdit.seam
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [ExceptionFilter] done running exception handlers
      15:14:52,018 INFO  [STDOUT] 15:14:52,018 DEBUG [BaseFilter] Finished request processing total time 31ms for uri: /reve/ReveSettoriEdit.seam
      15:14:52,472 INFO  [STDOUT] 15:14:52,472 DEBUG [BaseFilter] Filter start request processing at 27.07.09 15:14  for uri: /reve/error.seam
      15:14:52,472 INFO  [STDOUT] 15:14:52,472 DEBUG [BaseFilter] Filter request output to XML
      15:14:52,472 INFO  [STDOUT] 15:14:52,472 DEBUG [BaseXMLFilter] XML filter service start processing request
      
      
      





      On the other side if I catch the exception the transaction is rolled back properly.
      Also this behaviour is not what I would expect as Yuan gives only three possibilites to force a rollback:








      1. RuntimeExceptions

      2. raise a @ApplicationException

      3. use @Rollback with return-value



      What do I miss here?


      Matthias