-->
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.  [ 4 posts ] 
Author Message
 Post subject: Tutorial - No session currently bound... error
PostPosted: Wed Nov 05, 2008 10:25 am 
Newbie

Joined: Mon Nov 03, 2008 6:14 am
Posts: 3
Hi,

I'm new to hibernate and having some trouble running the "first Hibernate Application" in hibernate-distribution-3.3.1.GA (hibernate-distribution-3.3.1.GA\project\tutorials\web)

The web app works fine, but when I try and run it as a standalone app (ie. running the EventManager class passing in the param "store" or "list") I get the error:

Code:
Exception in thread "main" org.hibernate.HibernateException: No session currently bound to execution context
   at org.hibernate.context.ManagedSessionContext.currentSession(ManagedSessionContext.java:74)
   at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
   at org.hibernate.tutorial.web.EventManager.listEvents(EventManager.java:78)
   at org.hibernate.tutorial.web.EventManager.main(EventManager.java:20)


I tried with Hibernate 3.2 and that works. Any suggestions on what I need to do in order to run this as a standalone app in 3.3.1 please?

Many thanks,
Andrew.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 11:05 pm 
Newbie

Joined: Mon Nov 03, 2008 6:14 am
Posts: 3
Hi,

I've been able to work this out for myself. The difference between the code in 3.2 and 3.3.1 seems to be this line in hibernate.cfg.xml:

In 3.3.1:

Code:
<property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>


In 3.2:

Code:
<property name="current_session_context_class">thread</property>


Changing it back to "thread" seemed to fix the error I was seeing. I'm still too new to this to understand what it means, but at least I can start playing now. :-)

Thought I'd post this in case it helps others...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2008 5:23 am 
Newbie

Joined: Mon Nov 03, 2008 6:14 am
Posts: 3
Maybe I'm just talking to myself here but...now I've fallen over at the next step.

If I call EventManager with the parameter "addpersontoevent", I am now getting this error:

Code:
Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
   at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
   at org.hibernate.tutorial.domain.Event_$$_javassist_0.getParticipants(Event_$$_javassist_0.java)
   at org.hibernate.tutorial.domain.Person.addToEvent(Person.java:72)
   at org.hibernate.tutorial.web.EventManager.addPersonToEvent(EventManager.java:112)
   at org.hibernate.tutorial.web.EventManager.main(EventManager.java:30)


It only happens in the 3.3.1 code, not in the 3.2 example.


Top
 Profile  
 
 Post subject: THANKS!
PostPosted: Tue Feb 17, 2009 10:43 pm 
Newbie

Joined: Tue Feb 17, 2009 10:41 pm
Posts: 1
Your post about problems with the tutorial was helpful to me. I had the same problem with the " org.hibernate.HibernateException: No session currently bound to execution context" message. Changing the entry to "thread" fixed it.

I see you encountered another problem. Did you ever get that resolved?

Thanks,
Jeremy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.