Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:43:47+00:00 2026-05-26T02:43:47+00:00

I have a java project using Spring 3.0 , JPA 2.0 with MyEclipse IDE

  • 0

I have a java project using Spring 3.0 , JPA 2.0 with MyEclipse IDE

Trying to convert some basic dao integration tests to spring and have run into a few issues. Here’s my setup:

LevelDAO

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;
    }
}

}

Unit Test

@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); 

    }

}

Persistence.Xml

<?xml version="1.0" encoding="UTF-8"?>
<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">
<persistence-unit name="t1" transaction-type="RESOURCE_LOCAL">
    <provider>
        org.eclipse.persistence.jpa.PersistenceProvider
    </provider>
    <class>com.nlg.model.Level</class>
    <properties>
        <property name="javax.persistence.jdbc.driver"
            value="com.mysql.jdbc.Driver" />
        <property name="javax.persistence.jdbc.url"
            value="jdbc:mysql://myserver.rds.amazonaws.com:3306/" />
        <property name="javax.persistence.jdbc.user" value="myuser" />
        <property name="javax.persistence.jdbc.password" value="mypass" />
    </properties>
</persistence-unit>

applicationContext.xml

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="t1" />
</bean>
<bean id="transactionManager"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory"
        ref="entityManagerFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />
<bean
    id="LevelDAO" class="com.nlg.model.LevelDAO">
    <property name="entityManagerFactory"
        ref="entityManagerFactory" />
</bean>

At first I recieved this

Value ‘2.0’ of attribute ‘version’ of element ‘persistence’ is not valid

So reading another post which suggested changing this to “1.0”

and now recieve

java.lang.IllegalStateException: Failed to load ApplicationContext

That issue was resolved with the < provider > tag however hasn’t fixed my issue:

org.springframework.transaction.CannotCreateTransactionException: 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].

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.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:43:48+00:00Added an answer on May 26, 2026 at 2:43 am
    • Unable to acquire a connection from driver [null], user [null] and URL [null]

    These are JPA 2.0 properties:

     <property name="javax.persistence.jdbc.driver"
            value="com.mysql.jdbc.Driver" />
     <property name="javax.persistence.jdbc.url"
            value="jdbc:mysql://myserver.rds.amazonaws.com:3306/" />
     <property name="javax.persistence.jdbc.user" value="myuser" />
     <property name="javax.persistence.jdbc.password" value="mypass" />
    

    So if you switched back to 1.0, you’d probably want:

    <property name="eclipelink.jdbc.url" value="jdbc:mysql://myserver.rds.amazonaws.com:3306/"/> 
    <property name="eclipelink.jdbc.user" value="myuser"/> 
    <property name="eclipelink.jdbc.driver" value="com.mysql.jdbc.Driver"/> 
    <property name="eclipelink.jdbc.password" value="mypass"/>
    

    But then I would recommend to solve “that other problem” and stay with 2.0

    Here is an example of JPA 2.0 over EclipseLink that works ( notice persistence version="2.0" ):

    <?xml version="1.0" encoding="UTF-8"?>
    <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">
    
      <persistence-unit name="eclipselinktest" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    
        <!-- list all classes -->
        <class>com.codesmuggler.model.User</class>
    
        <properties>
          <!-- some properties needed by persistence provider:
            - driver
            - db url
            - db user name
            - db user password -->
          <property name="javax.persistence.target-database" value="PostgreSQL"/>
          <property name="javax.persistence.logging.level" value="INFO"/>
          <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
          <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/testdb"/>
          <property name="javax.persistence.jdbc.user" value="testuser"/>
          <property name="javax.persistence.jdbc.password" value="testpassword"/>
    
          <!-- for testing purpose every time application is launched drop and create tables
            in production mode - this line should be removed or commented out
          -->
          <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
    
        </properties>
    
      </persistence-unit>     
    </persistence>
    

    Take a look at the example in full

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a project using Spring MVC and JPA but I have
I have a Java project connecting to an Ingres database and using the Spring
I have created a simple java web (Vaadin) application project using JPA and it
I have a Java project that I build using an Ant script. I am
I have a Maven Java project, imported using m2eclipse . The target/ directory is
I have recently created a web project in Java using eclipse. I have a
I have a Java project that I'm trying to implement with a model-view-controller design.
I have a web project built in eclipse using Spring and for Tomcat. Before
I have a multi module Spring project that I set up using Maven: my-root
I'm a php programmer now doing a Java web project using Spring framework. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.