• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Spring + Hibernate No Session found for current thread

 
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java based spring mvc configuration

Dispatcher


Web config. ViewResolver bean


RootConfig. Bean for DataSource , LocalSessionFactoryBean , BeanPostProcessor

Interface for persistence logic

How i try use hibernate to save object

Controller:

Object that i want for save:

View
JSP where i place form for saving object


finally when i try save object i get:

org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcher] in context with path [/Spring_Demo_Aplication] threw exception [Request processing failed; nested exception is org.springframework.orm.hibernate4.HibernateSystemException: No Session found for current thread; nested exception is org.hibernate.HibernateException: No Session found for current thread] with root cause
org.hibernate.HibernateException: No Session found for current thread
at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:106)
at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:1013)
at com.myspringapp.config.persistance.HebernatePersist.saveObject(HebernatePersist.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)



And cant figure where error i made. How can i solve this problem?
 
Sergej Smoljanov
Ranch Hand
Posts: 472
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My solution was
add
@EnableTransactionManagement to class RootConfig
also add next bean to this class


also i change HibernatePersist this way and this will work for me

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic