You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jason Dyer <jd...@bluetarp.com> on 2006/05/08 19:13:40 UTC
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org