Hi David,

there are two things that made me think that there is no now transaction:

a) geronimo log (log level INFO)
if I make the annotation on bean class level, I got logs like:

16:19:35,968 INFO [Transaction] TX RequiresNew: Suspended transaction org.apache.geronimo.transaction.manager.transactioni...@1c21ffe 16:19:35,968 INFO [Transaction] TX RequiresNew: Started transaction org.apache.geronimo.transaction.manager.transactioni...@377dda 16:20:46,687 INFO [Transaction] TX RequiresNew: Committing transaction org.apache.geronimo.transaction.manager.transactioni...@377dda 16:20:46,859 INFO [Transaction] TX RequiresNew: Resuming transaction org.apache.geronimo.transaction.manager.transactioni...@1c21ffe

This lines are missing if the annotation is on bean method level

b) if the caller of the bean method rolls back it's transaction, the updates done in doAction are also rolled back.



I think I've found the reason, but I'm not sure, whether this is a bug or it's like defined in the specs.

If the bean method is called via remote interface from outside (the jvm), e.g. remote client, a new transaction is started, that's ok.

In my case the bean method is called via local interface from another bean:

CallerBean.doCall () [REQUIRES] => MyBean.doAction () [REQUIRES_NEW]

@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
public class CallerBean implements CallerBeanRemote {

  @EJB(name="ejb/MyBean")
  private MyBeanLocal myBean ;

  int doCall () {
  ....
int hlp = myBean.doAction () ; // call myBean via local iface, should start new transaction, but does not.
  ...
  }

Do the call via local interface not look at the method's TransactionAttribute, but the bean class' TransactionAttribute ?

Thanks a lot.

Norbert

David Blevins schrieb:
Hi Norbert,

If you can give some details on how you are determining that there is no new transaction that'd be great.

We do log all the transaction attributes for each method (i.e. the final values after defaults and overriding) on the log category 'OpenEJB.start.attributes' on the DEBUG level. If you can turn that on (post to u...@geronimo if you need help with that) and post the attributes for the methods in question that would also be great.

-David

On Mar 5, 2009, at 1:59 AM, Norbert Rieger wrote:

Hi,

I'm using Apache Geronimo 2.1.3 with openejb 3.0 (and openjpa 1.0.3).

When defining the TransactionAttribute (REQUIRES_NEW) on bean level it works fine, current transaction (call from other bean) is resumed,
a new transaction is started and committed after leaving doAction ().

@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public class MyBean implements MyBeanLocal {
    @PersistenceContext(unitName="MY_PU")
  private EntityManager em;

  int doAction () {
  ....
  }


But when defining the TransactionAttribute (REQUIRES_NEW) on method level (doAction) it seems that this has no effect :-(


@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class MyBean implements MyBeanLocal {
    @PersistenceContext(unitName="MY_PU")
  private EntityManager em;

  @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
   int doAction () {
  ....
  }

There is no new transaction.



What's wrong with my code in the second example (do I have to put the annotation on the local/remote interface) ?

Is this a bug in my definition or a bug in openEJB 3.0 ?

Thanks a lot for your help

Norbert





Reply via email to