CICS exception handling in Java Web applications

CICS® ABENDs and exceptions are integrated into the Java™ exception-handling architecture for the Liberty Web container to handle problems that occur in CICS applications. Any Java exception that is not handled by a Web application will be caught by the Web container and drive the servlet exception handling process. As part of this processing any uncommitted CICS units of work will be rolled back by CICS.

All Java Web applications that extend the HttpServlet interface must handle all checked exceptions apart from IOException or ServletException , as defined on the HttpServlet interface. Checked exceptions included all sub-classes of com.ibm.cics.server.CicsConditionException that represents unhandled CICS conditions. Therefore any exception handling code that catches CICS conditions must identify any error conditions which require a unit-of-work to be rolled back and either explicitly call syncpoint rollback using the rollback() method on the Task object, as illustrated in the example, or throw an AbendException.

try
{
    TSQ tsqQ = new TSQ();
    tsqQ.setName("tsq1");
    tsqQ.writeString("input data");
    
} catch (IOErrorException e) {
    // Log error
    try
    {
        Task.getTask().rollback();
        
        } catch (InvalidRequestException e1) {
            throw new RuntimeException(e1);
        }
    }
}

Unchecked Java exceptions, which are sub-classes of java.lang.RuntimeException, can be thrown by any Java application including Web applications, and include com.ibm.cics.server.AbendException and com.ibm.cics.server.AbendCancelException. Therefore any Web application that throws an AbendException or does not handle a transaction abend will drive the servlet exception handling process and associated unit-of-work rollback processing.

Web applications that commit units-of-work using the Java Transaction API (JTA) will be committed according to the control of the Liberty Transaction Manager. For further details see Java Transaction API (JTA).



dfhpjlm.html | Timestamp icon Last updated: Monday, 5 June 2017