bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Platform > WebLogic Integration > BPM Topics > Programming BPM Client Apps > Monitoring Workflow Exceptions |
Programming BPM Client Apps
|
Monitoring Workflow Exceptions
This section explains how to monitor workflow exceptions, including the following topics:
For information about monitoring workflow exceptions using the WebLogic Integration Studio, see Handling Workflow Exceptions in Using the WebLogic Integration Studio.
Overview of Exception Handling
The BEA WebLogic Integration exception handling facility enables you to generate, trap, and respond to generated exception conditions at run time. Exception handling is performed at the workflow level, rather than the task level.
The following sections describe workflow exceptions and exception handlers. For more information about exception handling, see Handling Workflow Exceptions in Using the WebLogic Integration Studio.
Workflow Exception
Workflow exceptions are either abnormal conditions that you define within a workflow, or typical run-time server exceptions that you trap and handle accordingly. A workflow exception may be thrown in response to one of numerous conditions, each of which is associated with an appropriate severity level.
The following table describes the levels of severity defined for workflow exceptions, including the severity code integer equivalents.
The com.bea.wlpi.common.WorkflowException object encapsulates a workflow exception that has occurred during the execution of a remote EJB call.
Exceptions are sent to the wlpiError JMS topic. For more information about connecting to JMS, see Establishing JMS Connections.
Workflow Exception Handler
All workflow template definitions specify at least one exception handler, the system exception handler. The system exception handler is, by default, the initial exception handler; it is invoked whenever an exception occurs. You can also define custom exception handlers. The active exception handler for a workflow template definition can be changed repeatedly in the course of the workflow.
Creating a Workflow Exception
The following table lists the constructors for creating a new WorkflowException object.
Getting Workflow Exception Information
The following sections explain how to get information about a workflow exception (such as severity, message text, message number, origin, and whether or not the workflow exception was caused by a deadlock) and how to print a stack trace.
Getting the Workflow Exception
To get the original or nested workflow exception, use the following com.bea.wlpi.common.WorkflowException methods, respectively:
public java.lang.Exception getOriginalException()
public java.lang.Exception getNestedException()
The first method returns the original workflow exception. The second method returns the nested workflow exception, or null, if no nested workflow exception exists.
For example, the following code gets the nested workflow exception for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
Exception nested e.getNestedException();
}
For more information about the getOriginalException() and getNestedException() methods, see the com.bea.wlpi.common.WorkflowException Javadoc.
Getting the Severity
To get the message severity for a workflow exception, use one of the following com.bea.wlpi.common.WorkflowException methods:
Method 1
public java.lang.String getSeverity()
Method 2
public java.lang.String getSeverityDescription()
Method 3
public java.lang.String getLocalizedSeverityDescription()
The first method returns the message severity code as an integer value. The second method returns the message severity value as a string value. The third method returns the localized message severity code as a string value. For information about severity level values and codes, see the table Workflow Exception Severity Levels.
For example, the following code gets the message severity code for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
String severity e.getSeverity();
}
For more information about the getSeverity() method, see the com.bea.wlpi.common.WorkflowException Javadoc.
Getting the Message Text
To get the message text associated with a workflow exception, use one of the following com.bea.wlpi.common.WorkflowException methods:
Method 1
public java.lang.String getMessage()
Method 2
public java.lang.String getLocalizedMessage()
The first method returns one of the following: the message text associated with a nested message, if available; the message text in the language of the system locale from which the exception was thrown; or null if no message text was created.
The second method returns the localized message text, if available, the message text in the language of the system locale from which the exception was thrown, or null, if no message text was created.
For example, the following code gets the message text for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
String message e.getMessage();
}
For more information about the getMessage() or getLocalizedMessage() method, see the com.bea.wlpi.common.WorkflowException Javadoc.
Getting the Message Number
To get the message number for a workflow exception, use the following com.bea.wlpi.common.WorkflowException method:
public java.lang.String getMessageNumber()
For example, the following code gets the message text for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
String number e.getMessageNumber();
}
For more information about the getMessageNumber() method, see the com.bea.wlpi.common.WorkflowException Javadoc.
Getting the Origin
To get the origin (workflow component) from which the workflow exception originated, use the following com.bea.wlpi.common.WorkflowException method:
public java.lang.String getOrigin()
For example, the following code gets the origin text for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
String origin e.getOrigin();
}
For more information about the getOrigin() method, see the com.bea.wlpi.common.WorkflowException Javadoc.
Determining Whether a Workflow Exception Resulted from a Database Deadlock
To determine whether or not the workflow exception resulted from a deadlock, use one of the following com.bea.wlpi.common.WorkflowException methods:
Method 1
public boolean isDeadlock()
Method 2
public static boolean isDeadlock(java.lang.Exception e)
Each method returns true if the workflow exception resulted from a database deadlock, and false otherwise.
The second method calls the getOrginalException() method to retrieve the original exception. If the original exception is an instance of java.sql.SQLException, the method calls the getSQLState() method to determine whether the original problem was a database deadlock.
For example, the following code determines whether a method is deadlocked for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
String boolean e.isDeadlock();
}
For more information about the isDeadlock() methods, see the com.bea.wlpi.common.WorkflowException Javadoc.
Printing the Stack Trace
To print a stack trace, use one of the following com.bea.wlpi.common.WorkflowException methods:
Method 1
public void printStackTrace()
Method 2
public void printStackTrace(java.io.PrintStream stream)
Method 3
public void printStackTrace(java.io.PrintWriter writer)
Each method prints the workflow exception and its back-trace. The first method prints the information to the standard error stream (System.err); the second, to the specified print stream; and the third, to the specified print writer.
The first line of the output contains the result of calling the toString() method for this object. The remaining content represents the data previously recorded by the fillInStackTrace() method. If the workflow exception contains a nested workflow exception, the method prints its stack trace, as well.
For example, the following code prints the stack trace for a given workflow exception:
try {
// some methods;
}
catch(WorkflowException e) {
e.printStackTrace();
}
For more information about the printStackTrace() methods, see the com.bea.wlpi.common.WorkflowException Javadoc.
Invoking a Workflow Exception Handler
To invoke a workflow exception handler for a workflow instance, use one of the following com.bea.wlpi.server.worklist.Worklist methods:
Method 1
public java.lang.String invokeWorkflowExceptionHandler(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String handlerName,
java.lang.String xml
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
Method 2
public java.lang.String invokeWorkflowExceptionHandler(
java.lang.String templateDefinitionId,
java.lang.String instanceId,
java.lang.String handlerName,
java.lang.String xml,
java.lang.Object transactionId
) throws java.rmi.RemoteException,
com.bea.wlpi.common.WorkflowException
The following table describes the invokeWorkflowExceptionHandler() method parameters for which you must specify values.
This method returns an XML document that is compliant with the Client Request DTD, ClientReq.dtd, as described in Client Request DTD. The XML document contains information about the running instance, and can be accessed by parsing the document using an XML parser, such as a SAX (Simple API for XML) parser. For example implementations of a SAX parser, see Examples of Managing Run-Time Tasks.
For example, the following code invokes the error handler, MyErrorHandler, passes the user-defined tree via the myXml string variable, and stores the resulting XML document to the clientReq variable. In this example, worklist represents the EJBObject reference to the Worklist EJB.
String clientReq = worklist.invokeWorkflowExceptionHandler(
definition.getId(), instanceID, "MyErrorHandler", myXml);
The template definition ID is obtained using the methods associated with the com.bea.wlpi.common.TemplateDefinitionInfo object, definition. An InstanceInfo object can be obtained using the methods described in Getting Workflow Instances. The instanceID can be obtained using the InstanceInfo object methods.
For more information about the com.bea.wlpi.common.TemplateDefinitionInfo methods, see TemplateDefinitionInfo Object. For more information about the com.bea.wlpi.common.InstanceInfo methods, see InstanceInfo Object.
For more information about the invokeWorkflowExceptionHandler() methods, see the com.bea.wlpi.server.worklist.Worklist Javadoc.
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |