Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ConcurrentAccessException with singleton bean

 
Himai Minh
Ranch Hand
Posts: 1296
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Singleton session bean indeed supports concurrent access, and various aspects of its concurrency can be tweaked using following annotations:


@ConcurrencyManagement
@Lock
@AccessTimeout

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic