Deploy TxnTestSSB bean (code below) into JBoss AS and run TxnTestSSBClient to invoke the bean.
With jboss-5.1.0.GA the client correctly displays:
hasTxn() returns: false
With jboss-6.0.0.Final the client wrongly displays:
hasTxn() returns: true
Try adding a hasTxn() method to TxnTestSSB and have it call super.hasTxn(). The client now correctly displays:
hasTxn() returns: false
=====================
TxnTestSSBRemote.java
=====================
import javax.ejb.Remote;
@Remote
public interface TxnTestSSBRemote
{
public boolean hasTxn();
}
===============
TxnTestSSB.java
===============
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Stateless
public class TxnTestSSB extends TxnTestSSBBase implements TxnTestSSBRemote
{
}
===================
TxnTestSSBBase.java
===================
import javax.annotation.Resource;
import javax.ejb.SessionContext;
public class TxnTestSSBBase
{
@Resource SessionContext ctx;
public boolean hasTxn()
{
try
{
ctx.getRollbackOnly();
return true;
}
catch (IllegalStateException e)
{
return false;
}
}
}
=====================
TxnTestSSBClient.java
=====================
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class TxnTestSSBClient
{
public static void main(String[] args) throws Exception
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
props.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext ctx = new InitialContext(props);
TxnTestSSBRemote remote = (TxnTestSSBRemote) ctx.lookup("TxnTestSSB/remote");
System.out.println("hasTxn() returns: " + remote.hasTxn());
}
}