title: spring+hibernate : Injection of autowired dependencies failed
body: <p>i did some search but i was unable to find out what's the problem.
  I'm aware the problem come from a ClassNotFoundException but i can't solve it.</p>
  
  <p>error : 
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.it.service.applicationService com.it.controller.applicationController.applicationService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean</p>
  
  <p>caused by :
  org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.it.service.applicationService com.it.controller.applicationController.applicationService; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean</p>
  
  <p>my conf :       version : 3.2.0.RELEASE</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;artifactId&gt;commons-logging&lt;/artifactId&gt;
                  &lt;groupId&gt;commons-logging&lt;/groupId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;version&gt;4.3.0.Beta1&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
          &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
          &lt;version&gt;3.5.6-Final&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>i autowired everything i need to (well, i think). here is my code :</p>
  
  <p>DAO class:</p>
  
  <pre><code>    package com.it.dao;
  
      import java.util.List;
  
      import org.hibernate.SessionFactory;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Repository;
  
      import com.it.model.application;
  
  
      @Repository("applicationDao")
      public class applicationDaoImpl implements applicationDao {
  
  @Autowired
  private SessionFactory sessionFactory;
  
  public void setSessionFactory(SessionFactory sessionFactory) {
      this.sessionFactory = sessionFactory;
  }
  
  
  public List&lt;application&gt; listeAll() {
      return sessionFactory.getCurrentSession()
              .createQuery("from application").list();
  }
  
      }
  </code></pre>
  
  <p>Service class :</p>
  
  <pre><code>    package com.it.service;
  
      import java.util.List;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;
      import org.springframework.transaction.annotation.Transactional;
  
      import com.it.dao.applicationDao;
      import com.it.model.application;
  
      @Service("applicationService")
      public class applicationServiceImpl implements applicationService {
  
  @Autowired
  private applicationDao applicationDao;
  
  
  @Transactional
  public List&lt;application&gt; listeAll() {
      return applicationDao.listeAll();
  }
  
      }
  </code></pre>
  
  <p>Controller class :</p>
  
  <pre><code>package com.it.controller;
  
  import java.util.Map;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  import com.it.model.application;
  import com.it.service.applicationService;
  
  @Controller
  @Configuration
  @ComponentScan("com.it.service")
  public class applicationController {
  
  @Autowired
  private applicationService applicationService;
  
  @RequestMapping("/index")
  public String listContacts(Map&lt;String, Object&gt; map) {
  
      map.put("application", new application());
      map.put("applicationList", applicationService.listeAll());
  
      return "application";
  }
  }
  </code></pre>
  
  <p>spring-servlet.xml :</p>
  
  <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
      p:packagesToScan="com.it" 
      p:dataSource-ref="dataSource"
      /&gt;
  
  
  &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/&gt;
  
  &lt;!-- Translates Hibernate exceptions to Spring Data Access Exceptions --&gt;
  &lt;bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/&gt;
  </code></pre>
  
  <p>here i try several thing, localSessionFactoryBean, annotationfactorybean, hibernate 3 or 4 etc.. but none is working :(</p>
  
  <p>also i have :</p>
  
  <pre><code>&lt;context:component-scan base-package="com.it.controller" /&gt;
  &lt;context:component-scan base-package="com.it.dao" /&gt;
  </code></pre>
  
  <p>and services should be scanned by annotation but i tried to declare scan in xml as well.</p>
  
  <p>If anyone can help me, it would be nice :)
  Thanks you in advance,
  Aure</p>