• Post Reply Bookmark Topic Watch Topic
  • New Topic

org.hibernate.HibernateException: No CurrentSessionContext configured!

 
VenkataPrasad Regula
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the below error



Where ever I search in google they are giving the following answer


The above line is already added in my config file I am pasting the config file and the code where I am getting the error below
hibernate.cfg.xml


Main Class


Error Stack

Step 1
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Step 2Exception in thread "main"
Sesssion Factory value org.hibernate.impl.SessionFactoryImpl@104c575
org.hibernate.HibernateException: No CurrentSessionContext configured!
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:685)
 
VenkataPrasad Regula
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My issue got resolved the change I have done is as follows

Session session = sessionFactory.getCurrentSession(); //Earlier I was using

Session session = sessionFactory.openSession(); //I changed the above line to this as shown

Now it is working fine.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!