DevPortal

How do I detect Deadlocks in EJBs?


Table of Contents


How do I detect Deadlocks in EJBs?

Most of the time the EJB container has to deal with a lot of concurrency issues while managing bean instances that need to be available to the application requesting for them. There are few deadlocks that might happen in the way application has been written.

Consider an example of a container running in the RR mode. In this mode, a component instance (EJB Object) is locked for the life span of a transaction and no other transaction can hold that component instance in any other transaction. The other transaction will have to wait for the first transaction to complete.

Now consider a scenario where two clients are concurrently running a transaction and one requires component instances 101 and 102 in that order and the other requires component instances 102 and 101, again in that order. This creates a deadlock.

Pramati Server detects such situations and would not allow transaction T1 to wait for the instance 102. The transaction would be rolled back.

How do I detect Deadlocks using server-config.xml?

To enable Pramati Server EJB container to detect such situations, two tags have been defined in the server-config.xml. These are:

<property name="data-collection-for-deadlock" value="true"/>
<property name="deadlock-detection" value="true"/>

The property value for the property name deadlock-detection should be set to true for deadlocks to be detected.

How do I detect Deadlocks using the Command Prompt?

Deadlocks can be detected using the Server shell prompt using the detectDeadlock command.

j2eeadmin@default> detectDeadlock
No Deadlocks Detected.

In the above case, no deadlocks are detected.


© Pramati Technologies 2007 Runs on Pramati Server | Feedback | Legal