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: no hibernatesessioncontext configured
PostPosted: Thu Mar 02, 2006 11:15 am 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
Hibernate version:
3.1.2

When calling sessionFactory.getCurrentSession() from a non managed environment I get a no hibernatesessioncontext configured error.

This works fine when running within JBoss.

I am using a copy of the HibernateUtil class from Christian's CaviatEmpror example to get the session factory.

I havn't been able to find anything on this error either within google or on the Hibernate forums.

Any help would be much apprecieated.

Regards

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 6:32 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Can you post the full exception trace? Also the code of getCurrentSession would be handy, assuming that it's the method that creates the session.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 4:15 am 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
getCurrentSession is a method on the SessionFactory (Released in Hibernate 3.1.2)

The stack trace is as follows:

org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:505)
at uk.co.ifdsgroup.security.dao.HibernateDAOFactory.getCurrentSession(HibernateDAOFactory.java:235)
at uk.co.ifdsgroup.security.dao.HibernateDAOFactory.getRealmDAO(HibernateDAOFactory.java:165)
at uk.co.ifdsgroup.security.dao.RealmDAOHibernateTest.testMakePersistent(RealmDAOHibernateTest.java:70)
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:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 5:57 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
That exception is only thrown if the session factory wasn't initialized. The current session context is set up in the constructor of SessionFactoryImpl, and there's no returns before it. So the only way it can't be there is if SessionFactory was never constructed, of if there was an exception during construction. Check earlier in your logging for other exceptions, and check your code for places that might catch exceptions and ignore them.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 6:05 am 
Beginner
Beginner

Joined: Wed Aug 04, 2004 4:33 am
Posts: 45
Location: Switzerland
you have to set the following property in the hibernate configuration:
<property name="current_session_context_class">thread</property>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 03, 2006 7:23 am 
Newbie

Joined: Sat Oct 29, 2005 1:23 pm
Posts: 15
Location: England
Excellent. Thanks

_________________
Jamie Cash
eCommerce Consultancy Limited
The eSecurity Experts


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.