I'm using Hibernate 2.1.1 and JBoss 3.2.3.
Here's some example code:
Code:
( ... )
session = sessionFactory.openSession();
transaction = session.beginTransaction();
Mp mp = (Mp)session.get(Mp.class, mp_id);
if(mp == null) {
log.error("MP was not found.");
throw new ObjectoNaoEncontradoException("MP was not found.");
}
mp.setEstado(estado);
session.saveOrUpdate(mp);
transaction.commit();
( ... )
Looking at the code we can see that if "mp" is null, a
ObjectNotFoundException is thrown, without doing any rollback.
When this happens, I get the following in the JBoss console:
Code:
10:49:02,656 WARN [MpBO] MP was not found.
10:49:02,718 WARN [SessionImpl] afterTransactionCompletion() was never called
10:49:02,718 WARN [SessionImpl] afterTransactionCompletion() was never called
And after a few minutes, I get the following:
Code:
10:53:12,187 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl [Format Id=257, GlobalId=sem-rede//23, BranchQual=] timed out. status=STATUS_ACTIVE
After this last situation, my web application doesn't work at all!?
It completely hangs up! This looks very catastrofic. Just one unrolled or uncommited transaction to put in danger a whole webapp.
Is this normal?
Shouldn't JBoss be aware of Hibernate's transactions?
I think the AS should "clean" up these situations.
Just to help, I have Hibernate as a SAR with the following jboss-service.xml:
Code:
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=ArsolHibernateFactory,
name=ArsolHibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=arsolDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">
mapping/ArmazemMistura.hbm.xml,
mapping/ArmazemMp.hbm.xml,
mapping/ArmazemPa.hbm.xml,
mapping/ArmazemPeca.hbm.xml,
mapping/Mp.hbm.xml
</attribute>
<attribute name="JndiName">java:/hibernate/ArsolHibernateFactory</attribute>
<attribute name="Datasource">java:/arsolDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.PostgreSQLDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">UserTransaction</attribute>
</mbean>
</server>
Please, need some information to understand this.