users@glassfish.java.net

Re: GFv1b14 Transaction problems

From: <glassfish_at_javadesktop.org>
Date: Thu, 14 Jun 2007 13:32:19 PDT

> Good question. No, it's perfectly safe.
> The second invocation will be serviced by a different
> bean instance,
> just as it would be for an invocation made from a
> different client
> component.

Ok, then could you please clarify the "Session Beans are not reentrant" policy then? One of my fears was what would happen if SessionBeanA called a method in SessionBeanB that then called a method in SessionBeanA.

But you're saying that if you're calling through the injected value, or the looked up reference, then you're getting a new instance, so you won't run in to this.

Is the rentrancy more an issue of accessing a bean from different threads?

I guess I'm curious how a developer MIGHT run into this problem, or would they have to go through some shenanigans to pull this off. Or, is this more a potential issue with Stateful Beans?

What would happen here:

@Stateless
public class SBA implements SBALocal {
    @EJB
    SBBLocal bBean;

    public void test() {
        bBean.test2(this);
    }

    public String hello() {
        return "hello";
    }
}

@Stateless
public class SBB implements SBBLocal {
    public void test2(SBALocal aBean) {
        System.out.println(aBean.hello());
    }
}

Is that a (contrived) case of reentrance?

Thanx for your time, this has always been one of those fringe aspects of JEE but it's never really clarified.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=222256