Tapernate relies on spring's ta-demarcation stuff to mark ta's for rollback. So, if something happens above your dao-layer, spring can't know it.
I override DirectService to this end, see below. Something similar should also work with tapernate-style SessionFactory instead of "svc". public class TransactionalDirectService extends DirectService { private PersistenceService svc; private Log log; public TransactionalDirectService( PersistenceService s ) { svc = s; } public void setLog( Log l ) { log = l; } @Override protected void triggerComponent(IRequestCycle cycle, IDirect direct, Object[] parameters) { try { log.debug("Trigger component transactional"); super.triggerComponent(cycle, direct, parameters); log.debug("Trigger component success - committing"); svc.commit(); } catch ( StaleObjectStateException e ){ log.debug("Stale object - rolling back"); svc.rollback(); cycle.activate("StaleObject"); } catch ( RuntimeException e ) { log.debug("Trigger component threw - rolling back"); svc.rollback(); throw e; } } } > -----Original Message----- > From: Jason Dyer [mailto:[EMAIL PROTECTED] > Sent: Monday, May 08, 2006 7:14 PM > To: Tapestry users > Subject: ServletRequestServicerFilter not getting exceptions? > > > I've written a ServletRequestServicerFilter for implementing an > open-session-in-view filter, much like the one in Tapernate > (in fact, I used > TapernateFilter as my reference.) > > In the no-exception case, it works fine. However, I was > assuming that page > exceptions would get thrown back to the filter and at that > point I could roll > back my Hibernate transaction. Unfortunately, exceptions > never seem to get > passed to the filter. > > So, my question. Is this a bug? If not, where would be the > proper place to > rollback transactions and so-forth when an exception is thrown? > > For reference, here's my code--it's pretty straight forward: > > public class HibernateServiceFilter implements > ServletRequestServicerFilter { > > private SessionManager sessionManager; > private String FLAG = this.getClass().getName() + ".ALREADY-CALLED"; > > public void service(HttpServletRequest request, HttpServletResponse > response, ServletRequestServicer servicer) throws IOException, > ServletException { > if (Boolean.TRUE.equals(request.getAttribute(FLAG))) { > servicer.service(request, response); > } else { > try { > request.setAttribute(FLAG, Boolean.TRUE); > servicer.service(request, response); > } catch (Throwable t) { > sessionManager.setToRollback(); > throw new ServletException("An exception was trapped by > HibernateServiceFilter.", t); > } finally { > sessionManager.endTransaction(); > } > } > } > > public void setSessionManager(SessionManager sessionManager) { > this.sessionManager = sessionManager; > } > } > > > TIA, > -Jason > > -- > > ---------------------- > People who push both buttons should get their wish. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]