-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Transaction hangs webapp!?
PostPosted: Wed Mar 10, 2004 8:11 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 11:29 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try to throw RuntimeException to abort transaction, but the most simple way to abort distributed transaction is to mark it as "rollbackOnly"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 12:38 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
baliukas wrote:
Try to throw RuntimeException to abort transaction, but the most simple way to abort distributed transaction is to mark it as "rollbackOnly"


Isn't "rollbackOnly" used for the EJB context for application exception situations!?
I'm not using Session Beans. Just concrete classes.
How can JBoss be aware of an unterminated transaction from Hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 1:14 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It must abort transaction if beans throws instans of RuntimeException,
I an not sure about checked application exeptions, I do not use this java 'feature'.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 1:41 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
baliukas wrote:
It must abort transaction if beans throws instans of RuntimeException,
I an not sure about checked application exeptions, I do not use this java 'feature'.


With RuntimeExceptions you don't need to explicitly rollback the transaction. The AS does this for you.
But that's not the point here because I'm not using EJB's.

I'm using plain old POJO's.
Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 1:57 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
If you are not using session beans, then you are probably not running inside any kind of application server transaction context. So you will probably have to do all your own exception management, including catching all exceptions and rolling back transactions yourself.

The application server can't manage your transactions if you don't use its managed transaction services, which it sounds like you're not really doing since all you have is plain POJOs. I mean, if you're just implementing a servlet inside JBoss, and if that servlet is just calling directly into your POJOs, then where exactly is JBoss getting a chance to interpose its own transaction context? Basically I think you are expecting JBoss to do some transaction handling for you without actually giving it any opportunity to do so :-)

Cheers,
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 7:39 pm 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
RobJellinghaus wrote:
If you are not using session beans, then you are probably not running inside any kind of application server transaction context. So you will probably have to do all your own exception management, including catching all exceptions and rolling back transactions yourself...


Your right!
Btw, thanks for the reply.
But tell me... not rolling back or commiting a transaction puts in danger a whole webapp!
That's my real concern. After those console lines that I've posted earlier, the webapp just wont respond. To any link.
So if I have Hibernate control completely my transactions and "forget" to handle a transaction, I put in danger the webapp.
Is this normal behaviour?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 7:41 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
I wouldn't think it's normal behavior, but I have no idea what part of JBoss is hanging or what the interaction between JBoss's servlet container and its JTA implementation might be. Is it possible for you to write a tiny test case that just makes a JDBC transaction (no Hibernate involved) and then fails to close the transaction, and see if that has the same behavior? If so, you could then post it to some JBoss forum and maybe get some help.

Cheers,
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Does it really hang on the first "forgotten" transaction or only if you pile up to many of them?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 5:10 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
michael wrote:
Does it really hang on the first "forgotten" transaction or only if you pile up to many of them?


I restart my JBoss and execute an operation like the one I've posted earlier, and that's enough to hang the webapp.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.