Errors that occur in the execution of a method of an EJB component are mapped to exception proxies and thrown to the calling script. The methods of all the classes in pbejbclient125.pbx can also throw exceptions when, for example, connection to the server fails or the component cannot be located or created.
Building EJB proxy projects generates the proxies for the home and remote interfaces, proxies for any Java classes referenced by the EJB, proxies for ancestor classes, and proxies for any exceptions that can be thrown by the EJB and its supporting classes. The following exception proxies are among those that may display in the System Tree:
Proxy name |
Java object name |
---|---|
createexception |
javax.ejb.CreateException |
ejbexception |
javax.ejb.EJBException |
finderexception |
javax.ejb.FinderException |
remoteexception |
java.rmi.RemoteException |
removeexception |
javax.ejb.RemoveException |
A client application can handle communications errors in a number of ways. For example, if a client connects to a server and tries to invoke a method for an object that does not exist, the client can disconnect from the server, connect to a different server, or retry the operation. Alternatively, the client can display a message to the user and give the user the opportunity to control what happens next.
When an error occurs, if the client connects to a new server to retry the operation, it must instantiate the remote object on the new server before invoking a method of the remote object.
In the following example, the script simply displays a message box when a specific exception occurs:
// function char getChar() throws RemoteException try conn.connectToServer(properties) mappinghome = conn.lookup("pbEjbMappingHome", "pbEjbTest/pbEjbMappingBeanSL", "pbejb.pbEjbMappingHome") mapping = mappinghome.create() ret = mapping.getChar() messagebox("char from EJB", ret) catch (remoteexception re) messagebox("remoteexception", re.GetMessage()) catch (createexception ce) messagebox("createexception", ce.GetMessage()) end try
If no exception handler exists, or if the existing exception handlers do not handle the exception, the SystemError event on the Application object is executed. If the SystemError event has no script, an application error occurs and the application is terminated.