users@glassfish.java.net

Trouble calling a _at_Remove method of a stateful bean during a CMT

From: <glassfish_at_javadesktop.org>
Date: Tue, 01 Sep 2009 12:24:42 PDT

Hi.

I'm using the Sun Glassfish Enterprise Server 2.1 (bundled with NetBeans 6.7) and I've got the following scenario:
- A stateless bean, let's call it A, initiates a container managed transaction
- in the business method I'm calling other stateless beans and two stateful beans (B and C)
- I call a @Remove-marked method of a stateful bean (B or C is the same)
- the next call to an EJB generates this exception
javax.ejb.TransactionRolledbackLocalException: Client's transaction aborted
        at com.sun.ejb.containers.BaseContainer.useClientTx(BaseContainer.java:3419)
        at com.sun.ejb.containers.BaseContainer.preInvokeTx(BaseContainer.java:3299)
        at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1244)
        at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:202)
        at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)

The structure of the code is this:

// stateless bean A
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class A implements ARemote {

    @EJB
    // some stateless bean injection here

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public MyType myOp(Param param) {
        // stateful bean lookups from SessionContext here
        // some invocation to beans here
        // first invocation to a @Remove-marked method of a stateful bean
        // next call here generate the exception
    }

It really seem like there's no way to call a @Remove-marked method of a stateful bean without breaking the transaction. Everything "works" if I don't do it, but I'm not going to leave instances of stateful beans hanging around.

Do you think I'm hitting a bug or it's "behaviour by design". As far as I can tell, the EJB 3.0 spec doesn't explicitely prohibit this. Otherwise, how would a stateless bean with container managed transaction be a client of a stateful bean?

Thanks for your help.
[Message sent by forum member 'emcrisostomo' (enrico.m.crisostomo_at_gmail.com)]

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