FileDocCategorySizeDatePackage
EJBException.javaAPI DocGlassfish v2 API5104Fri May 04 22:35:54 BST 2007javax.ejb

EJBException

public class EJBException extends RuntimeException
The EJBException exception is thrown by an enterprise Bean instance to its container to report that the invoked business method or callback method could not be completed because of an unexpected error (e.g. the instance failed to open a database connection).

Fields Summary
private Exception
causeException
Constructors Summary
public EJBException()
Constructs an EJBException with no detail message.


                  
      
    
public EJBException(String message)
Constructs an EJBException with the specified detailed message.

        super(message);
    
public EJBException(Exception ex)
Constructs an EJBException that embeds the originally thrown exception.

        super();
	causeException = ex;
    
public EJBException(String message, Exception ex)
Constructs an EJBException that embeds the originally thrown exception with the specified detail message.

        super(message);
	causeException = ex;
    
Methods Summary
public java.lang.ExceptiongetCausedByException()
Obtain the exception that caused the EJBException being thrown.

	return causeException;
    
public java.lang.StringgetMessage()
Returns the detail message, including the message from the nested exception if there is one.

	String msg = super.getMessage();
        if (causeException == null)
            return msg;
        else if ( msg == null ) {
            return "nested exception is: " + causeException.toString();
	}
	else {
            return msg + "; nested exception is: " + causeException.toString();
	}
    
public voidprintStackTrace(java.io.PrintStream ps)
Prints the composite message and the embedded stack trace to the specified stream ps.

param
ps the print stream

        if (causeException == null) {
            super.printStackTrace(ps);
        } else {
            synchronized(ps) {
		ps.println(this);
		// Print the cause exception first, so that the output
		// appears in stack order (i.e. innermost exception first)
                causeException.printStackTrace(ps);
                super.printStackTrace(ps);
            }
        }
    
public voidprintStackTrace()
Prints the composite message to System.err.

        printStackTrace(System.err);
    
public voidprintStackTrace(java.io.PrintWriter pw)
Prints the composite message and the embedded stack trace to the specified print writer pw.

param
pw the print writer

        if (causeException == null) {
            super.printStackTrace(pw);
        } else {
            synchronized(pw) {
		pw.println(this);
		// Print the cause exception first, so that the output
		// appears in stack order (i.e. innermost exception first)
                causeException.printStackTrace(pw);
		super.printStackTrace(pw);
            }
        }