This week's book giveaway is in the Agile forum.
We're giving away four copies of Head First Agile and have Andrew Stellman & Jennifer Greene on-line!
See this thread for details.
Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reentrant calls on entity beans  RSS feed

 
rajesh LM
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Reentrant property of my entity bean has been set as False. I believe that reentrant speaks mainly for the loopback within the same transaction context. My question is can different client programs invoke same method on the entity bean instance at the same point of time ?

for eg. two clients are accessing the same entity bean method in a loop. I am sure that in my code, recursive
behaviour is not there.

I such a situation I got "EJBException : Reentrant method call detected". I have tested setting the reentrant option as True and it was observed that the container exception is not seen anyfurther.

Can I take it like, the container cannot route multiple requests to the same instance and hence the exception ?

Response to this shall be highly appreciated.

Regards,

Rajesh
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a common mis-conception that reentrant just applies to loopback calls. It really applies to concurrent access to a given bean instance of the Entity Bean in question. So basically by setting reentrant to true you are saying that more than one thread can access the same exact bean instance (or database row if you will) at the same time. This is actually a huge restriction with using Entity Beans prior to EJB 3.0.

So from the sounds of it your two clients are trying to access the same data... therein lays the problem.
 
rajesh LM
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Chris,

Thanks for your valuable reply.

>>>>It is a common mis-conception that reentrant just applies to loopback >>>>calls. It really applies to concurrent access to a given bean instance >>>>of the Entity Bean in question.

Can you please tell me the document reference from where you have seen that it really applies concurrent calls ?. This will help me to have more details on that.

Regards,

Rajesh
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the EJB 2.1 Specification, Section 10.5.12 Non-reentrant and Re-entrant Instances:


An entity Bean Provider can specify that an entity bean is non-reentrant. If an instance of a non-reentrant entity bean executes a client request in a given transaction context, and another request with the same transaction context arrives for the same entity object, the container will throw an exception to the second request. This rule allows the Bean Provider to program the entity bean as single-threaded, non-reentrant code.


[ April 13, 2006: Message edited by: Chris Mathews ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!