Table B-2 summarizes the operations that are legal
for a stateless session bean. The allowed operations are the same for
both EJB 2.0 and 1.1, except for the
SessionContext
methods
getEJBLocalHome()
and
getEJBLocalObject()
, which are specific to EJB
2.0.
Table B-2. Allowed operations for stateless session beans
Method |
Allowed operations | |
---|---|---|
Container-managed transactions |
Bean-managed transactions | |
|
JNDI ENC contexts: Properties: |
JNDI ENC contexts: Properties: |
Business methods |
JNDI ENC contexts: Properties: Resource managers: EJB references: |
JNDI ENC contexts: Properties: Resource managers: EJB references: |
|
Not supported (stateless beans do not use these methods) |
Not supported (stateless beans do not use these methods) |
Table B-3 summarizes the operations that are legal
for a stateful session bean. The allowed operations are the same for
both EJB 2.0 and 1.1, except for the
SessionContext
methods
getEJBLocalHome()
and
getEJBLocalObject()
, which are specific to EJB
2.0.
Table B-3. Allowed operations for stateful session beans
Method |
Allowed operations | |
---|---|---|
Container-managed transactions |
Bean-managed transactions | |
|
JNDI ENC contexts: Properties: |
JNDI ENC contexts: Properties: |
|
JNDI ENC contexts: Properties: Resource managers: EJB references: |
JNDI ENC contexts: Properties: Resource managers: EJB references: |
Business methods |
JNDI ENC contexts: Properties: Resource managers: EJB references: |
JNDI ENC contexts: Properties: Resource managers: EJB references: |
|
JNDI ENC contexts: Properties: Resource managers: EJB references: |
Not supported (bean-managed transaction beans cannot implement the
|
|
JNDI ENC contexts: Properties: |
Not supported (bean-managed transaction beans cannot implement the
|
Table B-4 summarizes what happens to a transaction if an exception is thrown while the transaction is in process.
Table B-4. Exception summary for session and entity beans
Transaction scope |
Transaction type attributes |
Exception thrown |
Container’s action |
Client’s view |
---|---|---|---|---|
Client-initiated transaction. The transaction is started by the client (application or EJB) and is propagated to the enterprise bean method. |
transaction-type = Container transaction-attribute =
|
Application exception |
If the EJB invoked Rethrow the application exception. |
Receives the application exception. The client’s transaction may or may not have been marked for rollback. |
System exception |
Mark the client’s transaction for rollback. Log the error. Discard the instance. Rethrow the JTA |
Remote clients receive the JTA
The client’s transaction has been rolled back. | ||
Container-initiatedtransaction. The transaction started when the EJB’s method was invoked and will end when the method completes. |
transaction-type = Container transaction-attribute =
|
Application exception |
If the EJB invoked If the EJB did not explicitly roll back the transaction, attempt to commit the transaction and rethrow the application exception. |
Receives the application exception. The EJB’s transaction may or may not have been rolled back. The client’s transaction is not affected. |
System exception |
Roll back the transaction. Log the error. Discard the instance. Rethrow the |
Remote clients receive the The EJB’s transaction was rolled back. The client’s transaction may or may not be marked for rollback, depending on the vendor. | ||
The bean is not part of a transaction. The EJB was invoked but does not propagate the client’s transaction and does not start its own transaction. |
transaction-type = Container transaction-attribute =
|
Application exception |
Rethrow the application exception. |
Receives the application exception. The client’s transaction is not affected. |
System exception |
Log the error. Discard the instance. Rethrow the |
Remote clients receive the The client’s transaction may or may not be marked for rollback, depending on the vendor. | ||
Bean-managed transaction. The stateful or stateless session EJB uses the
|
transaction-type = Bean transaction-attribute = Bean-managed transaction EJBs do not use transaction attributes. |
Application exception |
Rethrow the application exception. |
Receives the application exception. The client’s transaction is not affected. |
System exception |
Roll back the transaction. Log the error. Discard the instance. Rethrow the |
Remote clients receive the The client’s transaction is not affected. |
Table B-5 summarizes the interactions between different types of exceptions and transactions in message-driven beans.
Table B-5. Exception summary for message-driven beans
Transaction scope |
Transaction type attributes |
Exception thrown |
Container’s action |
---|---|---|---|
Container-initiated transaction. The transaction started before the |
transaction-type = Container transaction-attribute =
|
System exception |
Roll back the transaction. Log the error. Discard the instance. |
Container-initiated transaction. No transaction was started. |
transaction-type = Container transaction-attribute =
|
System exception |
Log the error. Discard the instance. |
Bean-managed transaction. The message-driven bean uses the |
transaction-type = Bean transaction-attribute = Bean-managed transaction EJBs do not use transaction attributes. |
System exception |
Roll back the transaction. Log the error. |