title: Spring 3.2 + Hibernate 4.2 : "The application must supply JDBC connections" - What is wrong with my configuration?
body: <p>I'm struggling to understand how to properly configure Spring 3.2 and Hibernate 4.2.  After working through several issues over the last few days, I ran into this exception while trying to execute a query in my DAO:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: The application must supply JDBC connections
  org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:62)
  org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:292)
  org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:214)
  org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:157)
  org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
  org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
  org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1426)
  org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:59)
  com.bsj.demo.rest.dao.DemoUserDaoImpl.getAllDemoUsers(DemoUserDaoImpl.java:41)
  </code></pre>
  
  <p>Here are my Spring and Hibernate files:</p>
  
  <p><strong>context.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                      http://www.springframework.org/schema/tx
                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                      http://www.springframework.org/schema/context
                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
  &lt;context:property-placeholder location="classpath:spring/data-access.properties"/&gt;
  
  &lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
      &lt;property name="jndiName" value="java:comp/env/jdbc/restdemo"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/&gt;
      &lt;/property&gt;
      &lt;property name="persistenceUnitManager"&gt;
          &lt;bean class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager"&gt;
               &lt;property name="defaultDataSource" ref="dataSource" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;context:component-scan base-package="com.bsj.demo.rest.*"&gt;
      &lt;context:include-filter type="annotation"  expression="org.springframework.stereotype.Repository" /&gt;
  &lt;/context:component-scan&gt;
  
  &lt;bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;context:spring-configured /&gt;
  &lt;context:annotation-config /&gt;
  &lt;bean class="com.bsj.demo.rest.spring.config.AppConfig"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>persistence.xml</strong></p>
  
  <pre><code>&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0"&gt;
  &lt;persistence-unit name="RESTDemoJPA" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>What am I missing?  My understanding is that with Spring defining the datasource and persistence unit, there should be very little configuration needed in the persistence.xml.  Am I completely wrong here?  </p>
  
  <p>Server is Tomcat 7, dependencies managed by Maven.  I understand this is a commonly asked question on SO, but after trying several solutions I have not found a way to resolve this problem.</p>