Was wird in die jta-Datenquelle von persistence.xml geschrieben?

Welchen Wert soll ich in <jta-data-source> meiner persistence.xml?

In der glassfish admin-panel erstellt habe ich eine datasource-name "abcDS". In meinem jndi.properties (innen src/test/resources) ich definierte es so:

[...]
abcDS=new://Resource?type=DataSource
abcDS.JdbcDriver=org.hsqldb.jdbcDriver
abcDS.JdbcUrl=jdbc:hsqldb:mem:testdb
abcDS.JtaManaged=true
[...]

Was soll ich in persistence.xml? Ich habe eine Menge von Varianten im Netz, wie: "jdbc/abcDS""java:/abcDS""abcDS". Welche ist die richtige? Und gibt es da eine Regel dafür? Ich verstehe, dass es um JNDI, aber...

Ich versuche zu schaffen, EMF in meinem unit-test:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("abc");

Dies ist, was ich bin immer in der log:

[...]
SEVERE: Could not find datasource: abcDS javax.naming.NameNotFoundException: 
    Name "abcDS" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:193)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
at org.apache.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java:115)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
[...]

InformationsquelleAutor der Frage yegor256 | 2010-10-29

Schreibe einen Kommentar