-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problems with Session and transaction handling?
PostPosted: Thu Mar 01, 2007 2:18 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Problems with Session and transaction handling?

JSF-Version: 1.1
Spring-Version: 1.2.8
spring-aop.ar Spring-Version: 1.2.4
Hibernate-version: 3.1.3
weblogic 8i

We are handling transaction By custom interceptor (TransactionInterceptor) while creating transaction we are getting following Exception

org.springframework.transaction.CannotCreateTransactionException
: Could not open Hibernate Session for transaction; nested exception is org.hibernate.SessionException: Session is closed!

In production it is erratic behavior . If we try second time it will not give Exception .We tried to reproduce with our full effort but once our twice it comes. What could be the reason.

Thanks in Advance

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: Check the business objects
PostPosted: Thu Mar 01, 2007 3:09 am 
Newbie

Joined: Mon Feb 19, 2007 12:54 am
Posts: 16
Location: banglore, india
Hi ,
We have faced the same problem. But when we did the root cause anaysis we found that the following.

In business object method we are opening a session and before returning we r closing the session.
But In one method we have made a call to one more method. So the secong method closed the session but the remaining part of the first method still using the session.

It may help You.

_________________
Banglore Developer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 4:29 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi vrsreenath,

Thanks for reply,

In your case you will get every time this exception. In My case This is first method which start in transaction and hibernate starts creating transaction while creating transaction its get this exception (some time).Other method we have used same session. As I told we have used Interceptor .Even method is not called .It gets exception before method call

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 5:15 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Our Hibernate Setting is

<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="JNDI" />
</bean>

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list><value>XYZ.hbm.xml</value></list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.connection.release_mode">auto </prop>
<prop key="hibernate.transaction.auto_close_session">false</prop>
<prop key="hibernate.show_sql">true</prop><prop key="hibernate.connection.autocommit">false</prop>
</props>
</property>
</bean>
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

and we are getting session by factory.getCurrentSession() in interceptor

That might help you guys to help me.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject: erratic behavior of TransactionInterceptor
PostPosted: Thu Mar 01, 2007 11:20 pm 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi,
Guys ,Hibernate Team .It is production issue. we are not able to reproduce in locally.Any suggestion that might help

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 17, 2007 11:43 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi all,

Just want to close that issue .It was due to threadlocal by Hibernate Util class pattern with in cluster env with TransactionInterceptor (Spring) .Because TransactionInterceptor also use threadlocal .So removing Hibernate Util from code had solved our problem.

_________________
Dharmendra Pandey


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