title: Exception : org.hibernate.SessionException: Session was already closed
body: <p>I am developing application using java + spring + hibernate + oracle. when i add the below property in my <strong>dispatcher-servlet.xml</strong> file. </p>
  
  <pre><code>&lt;prop key="hibernate.transaction.auto_close_session"&gt;true&lt;/prop&gt;
  </code></pre>
  
  <p>It throws exception as below : </p>
  
  <pre><code>org.hibernate.SessionException: Session was already closed
  at org.hibernate.impl.SessionImpl.close(SessionImpl.java:302)
  at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSession(SessionFactoryUtils.java:791)
  at org.springframework.orm.hibernate3.SessionFactoryUtils.closeSessionOrRegisterDeferredClose(SessionFactoryUtils.java:777)
  at org.springframework.orm.hibernate3.HibernateTransactionManager.doCleanupAfterCompletion(HibernateTransactionManager.java:737)
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1011)
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:804)
  at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
  at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
  at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
  at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
  at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
  at $Proxy354.getMenu4Priv(Unknown Source)
  at com.itzcash.easy.reports.controller.SalesDistributionReportController.searchCustomerProfile(SalesDistributionReportController.java:261)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
  at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
  at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
  at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
  at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
  at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
  at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:208)
  at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:181)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
  at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
  at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>if i remove this property no exception is occurred. </p>
  
  <p>My code is like below :</p>
  
  <pre><code>  @Service
      Class ABCServiceImpl 
  {
      @Transactional
      void methodA()
      {
         // called the method in DAOImpl package -- methodB().
      }
  
  }
  
  @Repository
  Class ABCDAOImpl
  {
      @Autowired
      SessionFectory s;
  
      void methodB()
      {
        // hibernate operatoion
      }
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>