Appendix A. Changes for version 1.1 of the EJB specification
WebSphere Application Server supports version 1.1 of the EJB
specification. This appendix describes features that are new or have
changed in version 1.1 and discusses migration issues for enterprise
beans written to version 1.0 of the EJB specification.
The following enterprise bean features are new or have changed for version
1.1.
- Environmental dependencies for enterprise beans are now specified using
entries in a JNDI naming context. An instance of an enterprise bean
creates a javax.naming.InitialContext object by invoking the
constructor with no arguments specified. It looks up the environment
naming context by using the InitialContext object under the name
java:comp/env.
- Primary keys are handled differently in version 1.1 of the EJB
specification. Entity bean providers are not required to specify the
primary key class for entity beans with container-managed persistence (CMP),
enabling the deployer to select the primary key fields when the bean is
deployed into a container.
- The deployment descriptor has enhanced support for application
assembly.
From the client's perspective, enterprise beans written to version
1.1 of the EJB specification appear nearly identical to enterprise
beans written to version 1.0 of the specification. However, the
following EJB 1.1 changes do affect clients:
- Enterprise beans written to version 1.1 of the EJB specification
are registered in a different part of the JNDI namespace. For example,
a client can look up the initial context of a version 1.0 enterprise
bean in JNDI by using the initialContext.lookup method as
follows:
initialContext.lookup("com/ibm/Hello")
The JNDI lookup for the equivalent version 1.1 enterprise bean
is:
initialContext.lookup("java:comp/env/ejb/Hello")
- The UserTransaction object is obtained differently for enterprise beans
written to version 1.1 of the EJB specification. Under version
1.0, it was obtained as:
initialContext.lookup("jta/UserTransaction")
Under version 1.1, it is obtained as:
initialContext.lookup("java:comp/UserTransaction")
- Because entity beans written to version 1.1 of the EJB
specification now support primitive primary keys (instead of having to
encapsulate them in a primary key class), the client needs to look up these
primitive keys directly. For example, a client can look up a primitive
key of the type java.lang.Integer as follows:
accountHome.findByPrimaryKey(new Integer(5))
Primary key classes are still supported, although their use for
primitive data types is deprecated.
From the application developer's perspective, the following changes
need to be made to make enterprise beans written to version 1.0 of the
EJB specification compatible with version 1.1 of the
specification.
- All deployment descriptors must be converted to the XML format specified
in version 1.1 of the EJB specification.
- In general, enterprise beans written to version 1.0 of the EJB
specification are compatible with version 1.1. However, you need
to modify or recompile enterprise bean code in the following cases:
- The return value of the ejbCreate method must be modified for all entity
beans with CMP. The ejbCreate method is now required to return the same
type as the primary key; the actual value returned must be null.
These beans also must be recompiled. For more information, see Implementing the ejbCreate and ejbPostCreate methods
- If the javax.jts.UserTransaction interface is used.
This interface has been renamed to
javax.transaction.UserTransaction. Enterprise beans that
use this interface must be modified to use the new interface name.
There have also been minor changes to the exceptions thrown by this
interface.
- If the getCallerIdentity or isCallerInRole methods of the
javax.ejb.EJBContext interface are used. These methods
were deprecated because the javax.security.Identity class is
deprecated under the Java 2 platform.
- If an entity bean uses the UserTransaction interface, which is not
permitted under version 1.1 of the EJB specification.
- If an entity bean whose finder methods do not define the FinderException
in the methods' throws classes. Under version 1.1, the
finder methods of entity beans must define this exception.
- If an entity bean uses the UserTransaction interface and implements the
SessionSynchronization interface. Entity beans can neither use the
UserTransaction interface nor implement the SessionSynchronization interface
under version 1.1.
- If a stateless session bean implements the SessionSynchronization
interface. Stateless session beans should not implement the
SessionSynchronization interface under version 1.1.
- If an enterprise bean violates any of the new semantic restrictions
defined in version 1.1 of the EJB specification.
- Throwing the javax.ejb.RemoteException exception from the
bean implementations is deprecated in version 1.1. This
exception should be replaced by the javax.ejb.EJBException or a
more specific exception such as the
javax.ejb.CreateException. The
javax.ejb.EJBException inherits from the
javax.ejb.RuntimeException and does not need to be explicitly
declared in throws clauses.
Declare the javax.ejb.RemoteException exception in the remote
and home interfaces, as required by RMI. Throwing this exception
directly by the bean implementation is deprecated. However, it can be
thrown by the container due to a system exception or by mapping an exception
thrown by the bean implementation.