I am using jboss 5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)
. And need to get business interface of the bean. That is necessary for transaction management.
So I have:
@Local
public interface MyBeanInterface {
void transactionalMethod();
}
@Stateless
public class MyBean implements MyBeanInterface {
@Resource
private SessionContext context;
private int aState;
public void someMethod() {
aState = 42;
context.getBusinessObject(MyBeanInterface.class).transactionalMethod();
}
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void transactionalMethod() {
System.out.println(aState); // 0!!!!!
}
}
For some reason I do not get the same bean, but new bean is created. That is disastrous as transactionalMethod
needs the state variable value to execute correctly.
What am I doing wrong, or that is a bug of jboss? By the way there is a bug which affects ability to get business object via bean's class: https://issues.jboss.org/browse/EJBTHREE-2126. Not sure however if it relates to my issue.