title: problems with applicationContext.xml, setting up Hibernate, Spring MVC, and MySql
body: <p>I am trying to setup SpringMVC 3.0 + Hibernate + MySql with Maven.
  Having frustrating issues with the applicationContext.xml.
  The controller to the service to the DAO works, just that I am having problems setting up Hibernate to MySql.</p>
  
  <p>Googled lots of stuff online but different tutorials have different instructions so I'm all messed up now.</p>
  
  <p>applicationContext.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context-3.0.xsd
          http://www.springframework.org/schema/mvc 
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
          http://www.springframework.org/schema/beans 
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
  &lt;context:component-scan base-package="com.ray.service.blog" /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /&gt;
  &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt;
  
  &lt;bean id="blogDao" class="com.ray.service.blog.dao.BlogDao"&gt;
      &lt;!-- &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt; --&gt;
      &lt;constructor-arg ref="sessionFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="blogService" class="com.ray.service.blog.services.BlogService" /&gt;
  
  &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="configLocation"&gt;
          &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="configurationClass"&gt;
          &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/ray" /&gt;
      &lt;property name="username" value="root" /&gt;
      &lt;property name="password" value="root" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Here's the first few lines of the stack trace:</p>
  
  <pre><code>[2012-01-04 10:17:27,265] ERROR [org.springframework.web.context.ContextLoader] Context initialization failed 
  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.ray.service.blog.controllers.BlogController.setBlogService(com.ray.service.blog.services.BlogService); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.ray.service.blog.services.BlogService.setBlogDao(com.ray.service.blog.dao.BlogDao); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blogDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
  </code></pre>
  
  <p>Let me know if you need more information... thanks!</p>