I'm experimenting an very strange behaviour with CMT in JBoss6.1+ accessing zos/390 DB2.
Enviroment is:
- JBoss 6.1+
- Linux Red Hat
- DB2 running in ZOS 390
- EJB3/JPA2
Transaction simply does not rollback with SystemExceptions. I tried BMT and surprisily does not works either. My BMT code is bellow:
@Stateless
@LocalBean
@TransactionManagement(TransactionManagementType.BEAN)
public class ManterPortabilidadeBean
implements PortabilidadeService {
@Inject
private UserTransaction tx;
@Override
public void incluirPortabilidade(...) {
try {
tx.begin();
//insert into database
daoPortabilidade.incluir(portabilidade);
if (1==1)
throw new EJBException("Bingo");
tx.commit();
} catch (Exception e) {
try {
tx.rollback();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
Well, the record is in database!!! Incredible!!! EJB Container ignores completely, does nothing.
Here is CMT code:
@Stateless
@LocalBean
@TransactionManagement(TransactionManagementType.CONTAINER)
public class ManterPortabilidadeBean
implements PortabilidadeService {
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void incluirPortabilidade(...) {
//insert into database
daoPortabilidade.incluir(portabilidade);
if (1==1)
throw new EJBException("Bingo");
}
}
I believe that DB2 is commiting automatically, like autocommit=true, but configuration informes that autocommit is false, see persistence.xml bellow:
<persistence-unit name="gecDS" transaction-type="JTA">
<jta-data-source>java:/jdbc/DB2SigecDS</jta-data-source>
<properties>
<property name="hibernate.dialect"value="org.hibernate.dialect.DB2390Dialect" />
<property name="hibernate.default_schema" value="GEC" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.connection.isolation" value="2" />
<property name="hibernate.connection.autocommit" value="false"/>
<property name="javax.persistence.jdbc.driver" value="com.ibm.db2.jcc.DB2Driver" />
</properties>
</persistence-unit>
I standalone.xml I have this configuration for datasource:
<datasource jta="false" jndi-name="java:/jdbc/DB2SigecDS" pool-name="jdbc/DB2SigecDS" enabled="true">
<connection-url>jdbc:db2://************</connection-url>
<driver-class>com.ibm.db2.jcc.DB2XADataSource</driver-class>
<driver>db2</driver>
<security>
<user-name>*******</user-name>
<password>*******</password>
</security>
</datasource>
Any idea, configuration??? Thx