aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes stateful session bean does not allow loopback(re-entry) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "stateful session bean does not allow loopback(re-entry)" Watch "stateful session bean does not allow loopback(re-entry)" New topic
Author

stateful session bean does not allow loopback(re-entry)

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
On Frits's notes p.17-18, stateful bean will trhwo an illegalLoopbackException (blocking reentry). Why it is designed in this way?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

This is what the specs say:

The container must ensure that only one thread can be executing a stateless or stateful session bean instance at any time. Therefore, stateful and stateless session beans do not have to be coded as reentrant. One implication of this rule is that an application cannot make loopback calls to a stateless or stateful session bean instance.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
Thanks for Frit's reply.

From the diagram on Frit's noted on p.18, loopback is just method 1on a bean calls method 2 on another bean, and method 2 calls method 3 on the first bean. Or method 1 calls method 3.
I don't see loop back is related to multiple threading.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

Yeah, I had the same doubts. The only logical explanation to this is that the container cannot always distinguish the thread related to the first method call (coming from the client) from the thread related to the second method call (coming from bean B). The good thing for us (developers) is that we don't have take the re-entrance into account.
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
Hi Frits. Thanks for your reply.
I guess the container needs two threads to do the loopback call. One thread is to handle the first method call (coming from a client) and another thread is to handle the second loopback method call (coming from bean B).
But with stateful and stateless bean, only one thread is allowed to execute on this bean. That may be why loopback call is not supported in stateful or stateless bean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stateful session bean does not allow loopback(re-entry)