openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Wellmann <>
Subject Re: Override "jta-data-source" with system properties?
Date Mon, 19 Jul 2010 15:42:46 GMT

Hmm, can you be a bit more specific about your "quick test"? How did you set
your datasource properties then?
Setting these two properties to "", I keep getting an exception regarding a
non-existent transaction manager.

Meanwhile, I've found a solution that works for me.


  <persistence-unit name="mymodel">

Test fixture set-up:

        Map<String, Object> props = new HashMap<String, Object>();

        props.put("javax.persistence.jdbc.driver", driver);
        props.put("javax.persistence.jdbc.url", url);
        props.put("javax.persistence.jdbc.user", user);
        props.put("javax.persistence.jdbc.password", password);

        // Properties for the alternate non-jta-data-source. We need to set
        // to override the jta-data-source in persistence.xml
        props.put("openjpa.Connection2DriverName", driver);
        props.put("openjpa.Connection2URL", url);
        props.put("openjpa.Connection2UserName", user);
        props.put("openjpa.Connection2Password", password);

        // create the schema
        EntityManagerFactory emf =
Persistence.createEntityManagerFactory(persistenceUnit, props);
        em = emf.createEntityManager();

The trick is you have to set both the Connection* and the Connection2*
properties. Don't ask me why, though...

Tested with OpenJPA 2.0.0.


View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message