-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cannot create transaction context
PostPosted: Mon Jun 16, 2008 12:31 pm 
Newbie

Joined: Mon Jun 16, 2008 11:27 am
Posts: 3
Hi ,
I get this error cannot create transaction context - infrequently. Not sure when it works and why.

Hibernate version:
I am using hibernate 3.0

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 24, 2008 4:55:55 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.t8.DAL.hibBeans.OriginalTransactionDetails" table="OriginalTransactionDetails" schema="dbo" catalog="SwiftWire_new">
<id name="transRefNum" type="string">
<column name="transRefNum" length="16" />
<generator class="assigned" />
</id>
<property name="debitAmount" type="big_decimal">
<column name="DebitAmount" precision="18" />
</property>
<property name="debitCurrency" type="string">
<column name="DebitCurrency" length="3" />
</property>
<property name="transactionDate" type="timestamp">
<column name="TransactionDate" length="23" not-null="true" />
</property>
<property name="debitValueDate" type="timestamp">
<column name="DebitValueDate" length="23" />
</property>
<property name="ourRef" type="string">
<column name="OurRef" length="50" />
</property>
<property name="creditAmount" type="big_decimal">
<column name="CreditAmount" precision="18" />
</property>
<property name="creditCurrency" type="string">
<column name="CreditCurrency" length="3" />
</property>
<property name="creditDate" type="timestamp">
<column name="CreditDate" length="23" />
</property>
<property name="creditValueDate" type="timestamp">
<column name="CreditValueDate" length="23" />
</property>
<property name="counterPartyRef" type="string">
<column name="CounterPartyRef" length="50" />
</property>
<property name="forexRate" type="big_decimal">
<column name="ForexRate" precision="18" not-null="false" />
</property>
<property name="postedAmount" type="big_decimal">
<column name="PostedAmount" precision="18" />
</property>
<property name="beneficiaryRef" type="string">
<column name="BeneficiaryRef" length="50" />
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
BUTransaction buTransaction = new BUTransaction();
OriginalTransactionDetails origTransDet = buTransaction.getTransactions(mtTransRefFieldNo, transRefNum);
OriginalTransactionDetailsHome origTDHome = new OriginalTransactionDetailsHome();
origTDHome.attachDirty(origTransDet);

Full stack trace of any exception that occurs:
org.hibernate.HibernateException: clear is not valid without active transaction
org.hibernate.HibernateException: clear is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
at $Proxy3.clear(Unknown Source)
at com.t8.DAL.OriginalTransactionDetailsHome.attachDirty(OriginalTransactionDetailsHome.java:61)
at com.t8.BAL.BUCase.saveCaseDetails(BUCase.java:86)
at com.t8.struts.action.UnableToApplyAction.saveTrans(UnableToApplyAction.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
UnableToApplyAction - cannot create transaction context
org.hibernate.HibernateException: clear is not valid without active transaction
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)
at $Proxy3.clear(Unknown Source)
at com.t8.DAL.OriginalTransactionDetailsHome.attachDirty(OriginalTransactionDetailsHome.java:61)
at com.t8.BAL.BUCase.saveCaseDetails(BUCase.java:86)
at com.t8.struts.action.UnableToApplyAction.saveTrans(UnableToApplyAction.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)

Name and version of the database you are using:
SQL Server 2005
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 24, 2008 4:55:55 PM by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="com.t8.DAL.hibBeans.OriginalTransactionDetails" table="OriginalTransactionDetails" schema="dbo" catalog="SwiftWire_new">
<id name="transRefNum" type="string">
<column name="transRefNum" length="16" />
<generator class="assigned" />
</id>
<property name="debitAmount" type="big_decimal">
<column name="DebitAmount" precision="18" />
</property>
<property name="debitCurrency" type="string">
<column name="DebitCurrency" length="3" />
</property>
<property name="transactionDate" type="timestamp">
<column name="TransactionDate" length="23" not-null="true" />
</property>
<property name="debitValueDate" type="timestamp">
<column name="DebitValueDate" length="23" />
</property>
<property name="ourRef" type="string">
<column name="OurRef" length="50" />
</property>
<property name="creditAmount" type="big_decimal">
<column name="CreditAmount" precision="18" />
</property>
<property name="creditCurrency" type="string">
<column name="CreditCurrency" length="3" />
</property>
<property name="creditDate" type="timestamp">
<column name="CreditDate" length="23" />
</property>
<property name="creditValueDate" type="timestamp">
<column name="CreditValueDate" length="23" />
</property>
<property name="counterPartyRef" type="string">
<column name="CounterPartyRef" length="50" />
</property>
<property name="forexRate" type="big_decimal">
<column name="ForexRate" precision="18" not-null="false" />
</property>
<property name="postedAmount" type="big_decimal">
<column name="PostedAmount" precision="18" />
</property>
<property name="beneficiaryRef" type="string">
<column name="BeneficiaryRef" length="50" />
</property>
</class>
</hibernate-mapping>

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 4:12 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Are you managing the session yourself? It might be due to using openSession, as opposed to getSession. Any chance?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: clear is not valid without active transaction
PostPosted: Mon Jun 23, 2008 4:31 am 
Newbie

Joined: Mon Jun 16, 2008 11:27 am
Posts: 3
I am using sessionFactory.getCurrentSession() for fetching the session and the transaction is being instantiated on the session that has been returned. The previous error had been resolved as a new session was being created in one of the classes.

My problem now is that the change works fine from my netbeans environment. However the same error pops up when we deploy the solution.

Any clues or pointers please?

Thanks & Regards
N Srinivasan


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