-->
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: No Hibernate Session bound to thread
PostPosted: Wed Jan 20, 2010 12:35 pm 
Newbie

Joined: Mon Oct 20, 2008 4:45 pm
Posts: 5
Am using Spring with Hibernate.
In one of my Dao Methods, am using getHibernateTemplate().getSessionFactory().getCurrentSession() to get the session.
It sometimes throws an exception:

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)

How do i avoid this.

_________________
Thank You,
Ajit


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Wed Jan 20, 2010 3:51 pm 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
apolarouthu@lexstream.biz wrote:
Am using Spring with Hibernate.
In one of my Dao Methods, am using getHibernateTemplate().getSessionFactory().getCurrentSession() to get the session.
It sometimes throws an exception:

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)

How do i avoid this.


can you post you spring configuration?


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Wed Jan 20, 2010 4:44 pm 
Newbie

Joined: Mon Oct 20, 2008 4:45 pm
Posts: 5
<bean id="myAppSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" depends-on="cacheProviderCacheManagerInjector">
<property name="dataSource" ref="myAppDataSource"/>
<property name="mappingResources">
<list> ... </list>
</property>
</bean>


<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="myAppSessionFactory" />
</bean>

_________________
Thank You,
Ajit


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Wed Jan 20, 2010 5:00 pm 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
is this a webapp? are you using OpenSessionInView filter?


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Thu Jan 21, 2010 11:55 am 
Newbie

Joined: Mon Oct 20, 2008 4:45 pm
Posts: 5
Yes it is a webapp but we dont use OpenSessionInView filter

_________________
Thank You,
Ajit


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Thu Jan 21, 2010 12:58 pm 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
so who's creating sessions if you don't use OSIV?

apolarouthu@lexstream.biz wrote:
Yes it is a webapp but we dont use OpenSessionInView filter


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Thu Jan 21, 2010 1:53 pm 
Newbie

Joined: Mon Oct 20, 2008 4:45 pm
Posts: 5
LocalSessionFactoryBean

_________________
Thank You,
Ajit


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Thu Jan 21, 2010 2:32 pm 
Beginner
Beginner

Joined: Thu Mar 29, 2007 3:33 pm
Posts: 24
Location: Washington DC
Sure but who is actually creating a session from the factory? OSIV filter does it and if you are not using it, what is doing in your application what OSIV filter does?


Top
 Profile  
 
 Post subject: Re: No Hibernate Session bound to thread
PostPosted: Sat Apr 24, 2010 1:42 am 
Newbie

Joined: Thu Apr 01, 2010 6:09 pm
Posts: 8
Hi Ajith

Can you let me know when you get this error? Tell em the exact scenario please. also paste the code in spring config files say serveletname-servlet.xml and pplicationcontext.xml

Check whether the http://javaprogrammingtips4u.blogspot.c ... excep.html helps you!

Thanks
Priya


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.