EJB container exception nesting
 Technote (FAQ)
 
Problem
A nesting exception occurs under the following three scenarios
 
Cause
The EJBContainer has been coded to comply with the EJB 2.0 Specification. The tables in section 18.3 of the spec. dictate what must be returned by the EJBContainer.
 
Solution
  • Problem:
    When a runtime exception is thrown by the container, it is wrapped by
    com.ibm.ejs.container.UnknownLocalException.

    com.ibm.ejs.container.UnknownLocalException:  ; nested exception is: java.lang.NullPointerException
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.mapException(LocalExceptionMappingStrategy.java:198)
    at com.ibm.ejs.container.LocalExceptionMappingStrategy.setUncheckedException(LocalExceptionMappingStrategy.java:266)
    at
    com.ibm.ejs.container.EJSDeployedSupport.setUncheckedLocalException(EJSDeployedSupport.java:316)


    Explanation:
    In the Local case, all exceptions thrown from within the Container processing are not mapped to UnknownLocalException.

    For example, CSIExceptions may be mapped to one of several EJBException subclasses (AccessLocalException, InvalidActivityLocalException, etc.). Vanilla EJBExceptions are not re-mapped. RemoteExceptions are mapped to EJBException. All other exceptions are mapped to UnknownLocalException (which is a subclass of EJBException) containing the root exception. This is done in compliance with the EJB specification that says that we must throw an EJBException. The EJBContainer subclasses in order to provide more meaningful exceptions when possible.


  • Problem:
    When an EJBException (which is a Runtime exception) or a checked exception is thrown from the container, the exception does not get wrapped. Why is this different?

    CNTR0019E: Non-application exception occurred while processing method "findByPrimaryKey". Exception data: javax.ejb.EJBException: class com.ibm.db2.jcc.b.ClientRerouteException


    Explanation:
    The EJBContainer does attempt to wrap the "root" exception in the EJBException whenever possible.


  • Problem:
    As per J2EE Spec, container has to throw an EJBException in case of any unchecked exception thrown by container. However, in WAS it is not the case, why?

    Bean method threw unchecked exception
    org.omg.CORBA.portable.UnknownException:   minor code: 0 completed: Maybe
    at com.ibm.ejs.csi.OrbUtilsImpl.mapException(OrbUtilsImpl.java:88)
    at com.ibm.ejs.container.RemoteExceptionMappingStrategy.mapEJBException(RemoteExceptionMappingStrategy.java:390)
    at com.ibm.ejs.container.RemoteExceptionMappingStrategy.mapException(RemoteExceptionMappingStrategy.java:111)
    at com.ibm.ejs.container.RemoteExceptionMappingStrategy.setUncheckedException(RemoteExceptionMappingStrategy.java:201)
    at com.ibm.ejs.container.EJSDeployedSupport.setUncheckedException(EJSDeployedSupport.java:294)


    Explanation:
    The EJBContainer does throw an EJBException (or subclass of EJBException)
    in the "unchecked exception" case.

For more information about EBJException, here is a link to the EJB 2.1 Specification.
 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > EJB Container
Operating system(s): AIX
Software version: 6.0
Software edition:
Reference #: 1199310
IBM Group: Software Group
Modified date: Feb 1, 2006