-->
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.  [ 9 posts ] 
Author Message
 Post subject: Transaction timeout
PostPosted: Tue Sep 19, 2006 2:12 pm 
Newbie

Joined: Fri Sep 15, 2006 10:18 am
Posts: 8
Hi,

I have written an embedded EJB application which extracts data from a series of CSV files and writes them to a MySQL 4.0.27 database. When it has been running for some time, I get the following error and exception (The stack trace is quite long so I have only included what I think is important):
Code:
WARN 19-09 17:35:46,385 (Log4JLogger.java:warn:104) -SQL Error: 0, SQLState: null

ERROR 19-09 17:35:46,385 (Log4JLogger.java:error:114) -Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1158683427861/16, BranchQual=null:1158683427861, localId=0:16]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=null:1158683427861/16, BranchQual=null:1158683427861, localId=0:16])

ERROR 19-09 17:35:46,401 (Log4JLogger.java:error:119) -get failed

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection

at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)

at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:56)

at com.triggersoft.model.dao.AccountTxHome.findEarlierByAccount(AccountTxHome.java:166)

From what I could find out from Googling it seems as though this is caused by a transaction timeout. Adding code to get the time when the data import begins and when the exception occurs suggests backs this up as the error always occurs after 5 minutes - this seems like a reasonable default timeout period. I have been unable to find out how I can change the timeout value however.

Thanks

Simon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 4:06 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Jep, JBoss default transaction timeout is 300s.

Look at jta-service.xml.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 4:50 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
Hi,

Thanks for the reply aleshj but I am not running my application in a jboss container I am using Embedded EJB therefore jta-service.xml is irrelevant. There must be something similar for embedded ejb but I am not sure what.

(BTW it was taking ages to receive the activation email for this forum yesterday, so I asked my colleage to post the original post using his account.)

Simon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 5:00 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Then look at the embedded-jboss-beans.xml; TransactionManagerInitializer (org.jboss.tm.TransactionManagerInitializer), InitialContextProperties.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 7:25 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
That makes sense but I'm still not sure what I need to put in here to get round my problem. I have tried the following:

Code:
   <bean name="InitialContextProperties" class="java.util.Hashtable">
      <constructor>
      <parameter class="java.util.Map">
            <map keyClass="java.lang.String" valueClass="java.lang.String">
               <entry>
                  <key>java.naming.factory.initial</key>
                  <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
               </entry>
               <entry>
                   <key>java.naming.factory.url.pkgs</key>
                   <value>org.jboss.naming:org.jnp.interfaces</value>
               </entry>
               <entry>
                     <key>TransactionTimeout</key>
                     <value>1</value>
               </entry>
            </map>
      </parameter>
      </constructor>
   </bean>


Hoping that my application would timeout after 1 second, but it still runs for 5 minutes. I've either completely missed the mark or I've got the key wrong.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 7:56 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Add this (<property name="transactionTimeout"><value>1</value></property>) line to TransactionManagerInitializer bean in embedded-jboss-beans.xml:

Code:
   <bean name="TransactionManagerInitializer" class="org.jboss.tm.TransactionManagerInitializer">
      <property name="xidFactory"><inject bean="XidFactory"/></property>
      <property name="initialContextProperties"><inject bean="InitialContextProperties"/></property>
      <property name="transactionTimeout"><value>1</value></property>
   </bean>



Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 10:18 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
Thats works great thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 10:21 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 11:26 am
Posts: 33
Would it be possible for you to point me in the direction of the documentation you found that it in? I did think that I would need to do something like that but could find out the property names etc anywhere.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 20, 2006 10:53 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
s1mm0t wrote:
Would it be possible for you to point me in the direction of the documentation you found that it in?


Plain old source code.

ps: don't forget to rate ;-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.