title: Could not open JPA EntityManager for transaction in Spring Test
body: <p>I have a java project using Spring 3.0 , JPA 2.0 with MyEclipse IDE</p>
  
  <p>Trying to convert some basic dao integration tests to spring and have run into a few issues. Here's my setup:</p>
  
  <p><strong>LevelDAO</strong></p>
  
  <pre><code>public class LevelDAO extends JpaDaoSupport implements ILevelDAO 
  {
  public void save(Level entity) {
      logger.info("saving Level instance");
      try {
          getJpaTemplate().persist(entity);
          logger.info("save successful");
      } catch (RuntimeException re) {
          logger.error("save failed", re);
          throw re;
      }
  }
  
  }
  </code></pre>
  
  <p><strong>Unit Test</strong></p>
  
  <pre><code>@Transactional
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration({ "classpath:applicationContext.xml"})
  @TransactionConfiguration(transactionManager="transactionManager", defaultRollback=false)
  public class LevelDaoImplTests {
  
   LevelDAO levelDao;
  
   @Test
   public void shouldSaveNewLevels() {
  
          levelDao= new LevelDAO();
          Level l = new Level();   
          l.setName = "test";
          levelDao.save(l); 
  
      }
  
  }
  </code></pre>
  
  <p><strong>Persistence.Xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0" 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"&gt;
  &lt;persistence-unit name="t1" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;
          org.eclipse.persistence.jpa.PersistenceProvider
      &lt;/provider&gt;
      &lt;class&gt;com.nlg.model.Level&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="javax.persistence.jdbc.driver"
              value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="javax.persistence.jdbc.url"
              value="jdbc:mysql://myserver.rds.amazonaws.com:3306/" /&gt;
          &lt;property name="javax.persistence.jdbc.user" value="myuser" /&gt;
          &lt;property name="javax.persistence.jdbc.password" value="mypass" /&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
      &lt;property name="persistenceUnitName" value="t1" /&gt;
  &lt;/bean&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory"
          ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  &lt;bean
      id="LevelDAO" class="com.nlg.model.LevelDAO"&gt;
      &lt;property name="entityManagerFactory"
          ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>At first I recieved this</p>
  
  <p><strong>Value '2.0' of attribute 'version' of element 'persistence' is not valid</strong></p>
  
  <p>So reading another post which suggested changing this to "1.0"</p>
  
  <p>and now recieve</p>
  
  <p>java.lang.IllegalStateException: Failed to load ApplicationContext</p>
  
  <p>That issue was resolved with the &lt; provider > tag however hasn't fixed my issue:</p>
  
  <p><strong>org.springframework.transaction.CannotCreateTransactionException:</strong> Could not open JPA EntityManager for transaction; nested exception is Exception [EclipseLink-4021] (Eclipse Persistence Services - 1.0.2 (Build 20081024)): org.eclipse.persistence.exceptions.DatabaseException
  Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  </p>
  
  <p>My concern is that by downgrading the version no. to "1.0" that I'm also overlooking the issue of compatibility within this stack. I have non-spring versions of these tests working, so any ideas on where I've gone wrong appreciated. </p>
  
  <p>Thanks</p>