title: hibernate4, spring 3: No Session found for current thread
body: <p>I've seen several similar questions, but none of the suggested solutions helped me.</p>
  
  <p>Detail, it's a simple exemple :</p>
  
  <p>File: <strong>MandatTypeBean.xml</strong>  </p>
  
  <pre><code>&lt;bean id="mandatTypeDAO" class="gestint.data.dao.impl.MandatTypeDAOImpl"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="ActionMandatType" class="gestint.data.action.MandatTypeAction"&gt;
      &lt;property name="mandatTypeDAO" ref="mandatTypeDAO" /&gt;
  &lt;/bean&gt;   
  </code></pre>
  
  <p>File: <strong>HibernateSessionFactory.xml</strong></p>
  
  <pre><code>&lt;bean id="sessionFactory" 
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
  
     &lt;property name="dataSource"&gt;
        &lt;ref bean="DataSource"/&gt;
      &lt;/property&gt;
  
      &lt;property name="hibernateProperties"&gt;
           &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;  
           &lt;/props&gt;
      &lt;/property&gt;
  
  
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
            &lt;value&gt;gestint/data/model/MandatType.hbm.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;  
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>File: <strong>MandatTypeDAO.java</strong></p>
  
  <pre><code>public class MandatTypeDAOImpl implements MandatTypeDAO {
  private SessionFactory sessionFactory;
  
  public SessionFactory getSessionFactory() {
      return sessionFactory;
  }
  public void setSessionFactory(SessionFactory sessionFactory) {
       this.sessionFactory = sessionFactory;
  }   
  
  public List&lt;MandatType&gt; listMandatType() {      
      sessionFactory.getCurrentSession().isConnected();       
  
      return null;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>File: <strong>MandatTypeAction.java</strong></p>
  
  <pre><code>public class MandatTypeAction extends ActionSupport{
      private static final long serialVersionUID = 1L;
  
      private MandatTypeDAO mandatTypeDAO;    
      private List&lt;MandatType&gt; mandatList = new ArrayList&lt;MandatType&gt;();
  
      public void setMandatTypeDAO(MandatTypeDAO mandatTypeDAO) {
          this.mandatTypeDAO = mandatTypeDAO;
      }
  
      public List&lt;MandatType&gt; getMandatTypeList() {
          return mandatList;
      }
  
      public String listMandatType() {            
          mandatList = mandatTypeDAO.listMandatType();
          return SUCCESS;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>And my error.. </p>
  
  <p>When I try to acces to 
  <code>public List&lt;MandatType&gt; listMandatType()</code> 
  with a simple linge for testing :</p>
  
  <pre><code>sessionFactory.getCurrentSession().isConnected();
  </code></pre>
  
  <p>I get this error :</p>
  
  <blockquote>
    <p>17:02:28,062 ERROR Dispatcher:38 - Exception occurred during
    processing request: No Session found for current thread
    org.hibernate.HibernateException: No Session found for current thread
      at
    org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)
      at
    org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:980)
      at
    gestint.data.dao.impl.MandatTypeDAOImpl.listMandatType(MandatTypeDAOImpl.java:21)
      at
    gestint.data.action.MandatTypeAction.listMandatType(MandatTypeAction.java:26)
      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:597)     at
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:446)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:285)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
      at
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
      at
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
      at
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
      at
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
      at
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
      at
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
      at
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
      at
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
      at
    weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:74)
      at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3288)
      at
    weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3254)
      at
    weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at
    weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at
    weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      at
    weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2163)
      at
    weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2089)
      at
    weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2074)
      at
    weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1512)
      at
    weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)  at
    weblogic.work.ExecuteThread.run(ExecuteThread.java:221)</p>
  </blockquote>
  
  <p>Somebody can help me ? </p>