title: Trouble with hibernate and spring xml configuration
body: <p>Hello guys i have been playing around with spring mvc and hibernate. But now i am getting an error when trying to connect both hibernate and spring with XML configuration. I get this error below:</p>
  
  <pre><code>03-Nov-2015 22:22:19.675 WARNING [RMI TCP Connection(2)-127.0.0.1] org.springframework.web.context.support.XmlWebApplicationContext.refresh Exception encountered during context initialization - cancelling refresh attempt
   org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personService' defined in ServletContext resource [/WEB-INF/services.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/services.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Error accessing stax stream
  </code></pre>
  
  <p>I created my webapp folder in <code>src/main</code>. in my webapp folder i created WEB-INF folder. And WEB-INF folder contained files: service.xml, dispatcher-servlet.xml. Now for my hibernate.cfg.xml, it was placed in src/main folder structure. But when i try to add it in the service.xml upon loading the dispatcher, my hibernate.cfg.xml seems not to be found. Does anyone know why? This is where i am having trouble:</p>
  
  <pre><code>&lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>I can't seem to find the value of configLocation. Has anyone encountered this issue.</p>
  
  <p>Below is my web.xml configuration:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
           version="3.1"&gt;
      &lt;display-name&gt;Lab 2&lt;/display-name&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/applicationContext.xml, /WEB-INF/services.xml&lt;/param-value&gt;
  
      &lt;/context-param&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>dispatcher-servlet.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:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  
      &lt;context:component-scan base-package="edu.sjsu.cmpe275.lab2.controller"  /&gt;
  
  
         &lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" /&gt;
         &lt;bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" /&gt;
  
        &lt;!-- &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
                &lt;property name="prefix" value="/WEB-INF/views/" /&gt;
                &lt;property name="suffix" value=".jsp" /&gt;
         &lt;/bean&gt; --&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>service.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:context="http://www.springframework.org/schema/context"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  
         &lt;bean name="personService" class="edu.sjsu.cmpe275.lab2.service.PersonImpl" autowire="byName"/&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/Lab2" /&gt;
                &lt;property name="username" value="root" /&gt;
                &lt;property name="password" value="root" /&gt;
         &lt;/bean&gt;
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="configLocation" value="" /&gt;
      &lt;/bean&gt;
      &lt;bean name="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager" &gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
              &lt;/bean&gt;
        &lt;context:component-scan base-package="edu.sjsu.cmpe275.lab2.service" /&gt;
     &lt;!-- &lt;bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /&gt; --&gt;
  &lt;/beans&gt;
  </code></pre>