+

Search Tips   |   Advanced Search

Rule Exception Handling in the run-time environment


The default method of error or exception handling within the Personalization run-time environment is for the engine to print out a trace error to the application server's stdout log. Using an exception handling utility, it is possible to specify the type of output (error message or stacktrace), the output log file to use (stdout or stderr), and whether the exception should be rethrown to the JSP. The additional exception handling capabilities can be set on a per-request basis or globally.


Per-request

To set the scheme on a per-request basis, include the following code within a content spot on a JSP:

request.setAttribute(RuntimeUtils.PZN_RUNTIME_EXCEPTION_HANDLING_KEY, RuntimeUtils.HANDLING_SCHEME);

Where HANDLING_SCHEME is one of the options specified for the setRuntimeExceptionHandlingScheme method described in the following section.

This method will only change the exception handling scheme for rules running on that JSP.


Global

To set the same scheme for every rule running on a server, execute the following code:

RuntimeUtils.setRuntimeExceptionHandlingScheme(RuntimeUtils.HANDLING_SCHEME);
To reset the global exception handling scheme, call:
RuntimeUtils.resetRuntimeExceptionHandlingScheme();

Restarting the application server will automatically reset the exception handling scheme.

We can also change the global behavior of the server by changing the following value in PersonalizationService.properties:

rulesEngine.exceptionHandling=logMessage_stdout

To make any changes effective, you must restart the server.


RuntimeUtils methods


Exception Handling Process

When an exception occurs, if the code can continue, it will do so while logging the exception. If not, the exception is wrapped in a PersonalizationException which is passed to RuleTrigger. RuleTrigger looks for a request override for the exception handling scheme, processes the scheme, and returns to the JSP. Any subclasses of Throwable might be wrapped in a PersonalizationException.


Tracing

To trace the runtime classes, enable trace for com.ibm.websphere.personalization.*=all. To trace the authoring portlet classes, enable trace for com.ibm.wps.caf.*=all.


Parent: Personalization programming reference