2017  Kodetalk | Feedback | Privacy Policy | Terms | About

Best way to catch all unhandled exceptions in all Tomcat (GWT) servlets

I am using Tomcat 7 and Lo4j for all my server logs and GWT for client (only AJAX calls).

All my unhandled exceptions get logged in my catalina.log.

Now I want to catch all exceptions and add some of the user"s specific Tomcat SessionData.

There are several ways:

  • Try catch over all servlets (there must be a better solution).
  • http://tomcat.apache.org/tomcat-7.0-doc/aio.html: I would have to change my connecter, and I don"t know if I could use the Tomcat Session within the Event Handler (EventType.ERROR).
  • Better way?

What would be the best way to achieve this?


Just Overriding the GWT function doUnexpectedFailure worked.


protected void doUnexpectedFailure(Throwable t) {

  ServerLog.error(t.getMessage(), t);



Answer is