File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ConcurrentAccessException with singleton bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ConcurrentAccessException with singleton bean" Watch "ConcurrentAccessException with singleton bean" New topic

ConcurrentAccessException with singleton bean

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 1118
On p.58 of Frits notes,

ConcurrentAccessException - Indicates that the client has attempted an invocation on a stateful session bean or singleton bean while another invocation is in progress and such concurrent access is not allowed.

However, on p.23 of the notes,

A singleton session bean instance is shared between clients and support concurrent access.

Due to the fact that a singleton session bean support concurrent access, why the single bean will throw ConcurrentAccessException?
Mike Degteariov
Ranch Hand

Joined: Oct 03, 2007
Posts: 143

Singleton session bean indeed supports concurrent access, and various aspects of its concurrency can be tweaked using following annotations:


So, for instance, if a concurrency management is in its default state (which is @ConcurrencyManagement(CONTAINER)) and the method is of locking type WRITE, client access to all the singleton’s methods is blocked until the current client finishes its method call or an access timeout occurs. When an access timeout occurs, the EJB container throws a javax.ejb.ConcurrentAccessTimeoutException - which is a child of javax.ejb.ConcurrentAccessException
In other cases, like, if a locking type used is READ, or @ConcurrencyManagement(BEAN) is used, simultaneous access to the bean is permitted, and ConcurrentAccessException will not be thrown upon concurrent calls.

Refer to the tutorial for further details.

Mike Degteariov
I agree. Here's the link:
subject: ConcurrentAccessException with singleton bean
It's not a secret anymore!