I’ve faced an interesting aim, this aim targets the exception handling in existing web application written with wicket and hibernate frameworks,
suppose we have web app which is deployed in server and sometimes it produces runtime exceptions, the problem is how to get and save their stacktrace to db without modifying all classes(about 80 models and 150 views).
Hope i gave all clear.
Thanks in advance.
Wicket 1.4 and earlier
Override
Application.newRequestCycle()and return a custom subclass ofWebRequestCyclethat overridesRequestCycle.logRuntimeException()in order to provide additional logging behavior for allRuntimeExceptions in your application. Notice that any uncaughtExceptionwill be wrapped by Wicket in aWicketRuntimeException(as stated in the Exception handling section of Request cycle and request cycle processor) :There, use a Service/DAO component that will insert the exception message along with the stacktrace into the database. Remember that depending on the dbms, you might want to use a CLOB instead of a varchar type (for instance, in Oracle, a varchar column cannot hold more than 4000 bytes).
Here’s an (untested) example:
Wicket 1.5 and later
See @Cristoph’s answer