title: java.lang.NoClassDefFoundError: org/springframework/orm/hibernate4/SpringSessionContext
body: <p>I am try to implement SpringMVC 4 and Hibernate 4 integration with annotation in my project  but I am getting this error:
  <strong><em>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in com.config.ApplicationContextConfig: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.hibernate.SessionFactory]: Factory method 'getSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/orm/hibernate4/SpringSessionContext</em></strong>
  My Config file is::</p>
  
  <pre><code>    import javax.sql.DataSource;
  import java.util.Properties;
  import org.hibernate.SessionFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.core.env.Environment;
  import org.springframework.jdbc.datasource.DriverManagerDataSource;
  import org.springframework.orm.hibernate4.HibernateTransactionManager;
  import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
  import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
  import org.springframework.transaction.annotation.EnableTransactionManagement;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  import org.springframework.orm.hibernate4.SpringSessionContext;
  import com.dao.UserDao;
  import com.dao.UserDaoImpl;
  import com.pojo.User;
  
  @Configuration
  @ComponentScan("com.config")
  @EnableTransactionManagement
  public class ApplicationContextConfig {
  
      @Bean(name = "viewResolver")
      public InternalResourceViewResolver getViewResolver() {
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setPrefix("/WEB-INF/views/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
      @Bean(name = "dataSource")
      public DataSource dataSource() {
           DriverManagerDataSource dataSource = new DriverManagerDataSource();
          dataSource.setDriverClassName("com.mysql.jdbc.Driver");
          dataSource.setUrl("jdbc:mysql://localhost:3306/usersdb");
          dataSource.setUsername("root");
          dataSource.setPassword("");
  
          return dataSource;
      }
      @Autowired
      @Bean(name = "sessionFactory")
      public SessionFactory getSessionFactory(DataSource dataSource) {
  
          LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
  
          sessionBuilder.addAnnotatedClasses(User.class);
  
          return sessionBuilder.buildSessionFactory();
      }
      private Properties getHibernateProperties() {
          Properties properties = new Properties();
          properties.put("hibernate.show_sql", "true");
          properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
          return properties;
      }
      @Autowired
      @Bean(name = "transactionManager")
      public HibernateTransactionManager getTransactionManager(
              SessionFactory sessionFactory) {
          HibernateTransactionManager transactionManager = new HibernateTransactionManager(
                  sessionFactory);
  
          return transactionManager;
      }
      @Autowired
      @Bean(name = "userDao")
      public UserDao getUserDao(SessionFactory sessionFactory) {
          return new UserDaoImpl(sessionFactory);
      }
  
  }
  </code></pre>