Hi Josef,
Couple questions. What Java version are you using? Are you setting "-
javaagent:<path-to>/openejb-javaagent-3.0.jar" as part of the test
parameters? (an openjpa specific requirement)
Also, try is adjusting your test setup to the following.
public void setUp() throws Exception {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
properties.put("Postgres.postgres.vesuv", "new://Resource?
type=DataSource");
properties.put("Postgres.postgres.vesuv.JdbcDriver",
"org.postgresql.Driver");
properties.put("Postgres.postgres.vesuv.JdbcUrl",
"jdbc:postgresql://localhost/bla");
properties.put("Postgres.postgres.vesuv.UserName", "bla");
properties.put("Postgres.postgres.vesuv.Password", "bla");
...
}
I.e. with the OpenEJB home and openejb.conf file cut out. We don't
need the openejb.home for testing and 100% of the configuration we do
need for testing can be supplied via the properties syntax you already
have in your TestCase. We use different "heavier" defaults (tx
logging is enabled for example) if we determine we're running as a
standalone server and setting an openejb.home to a directory
containing a "conf/" directory is one way we determine that.
If you did want to declare your TransactionManager and SecurityService
and more, you could do so in your test case as follows:
properties.put("myTransactionManager", "new://
TransactionManager");
properties.put("mySecurityService", "new://SecurityService");
properties.put("myStatelessContainer", "new://Container?
type=STATELESS");
properties.put("myStatefulContainer", "new://Container?
type=STATEFUL");
However we will automatically create all of these as needed so there's
no reason to explicitly declare them unless you wish to override a
value.
If you're comfortable posting your full log file output that can help
too.
-David
On Jun 5, 2008, at 2:28 AM, [EMAIL PROTECTED] wrote:
Hi All,
great Idea to do unit-testing using the embedded functions of
openejb. So
I tried...
I have a JavaEE-5 application on Geronimo 2.1.1 with Postgres-DB.
(Driver
postgresql-8.2-508.jdbc3.jar). In Geronimo I defined a database pool
with
Pool-Type "TranQL XA Resource Adapter for PostgreSQL". I use Local
Session
Beans in General. The Application works quite well.
Thus I tried to do this with embedded openejb. After quite a few
problems
to set up the system, my JUNIT-Test works up to a certain step. It
seems
there is maybe an impact with the transaction - functionality. The
transaction could not be comitted. I could imagine not the XA-
Datasource
is taken, but who knows??
openejb.conf:
...
<SecurityService id="Default Security Service"/>
<TransactionManager id="Default Transaction Manager"/>
</openejb>
JUNIT-Testcase:
public void setUp() throws Exception {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
properties.put("openejb.home",
"/home/user/workspace/VesuvUnit/openejb");
properties.put("openejb.configuration",
"/home/user/workspace/VesuvUnit/openejb/
openejb.conf");
....
properties.put("Postgres.postgres.vesuv",
"new://Resource?type=DataSource");
properties.put("Postgres.postgres.vesuv.JdbcDriver",
"org.postgresql.Driver");
properties.put("Postgres.postgres.vesuv.JdbcUrl",
"jdbc:postgresql://localhost/bla");
properties.put("Postgres.postgres.vesuv.UserName",
"bla");
properties.put("Postgres.postgres.vesuv.Password",
"bla");
....
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="VesuvPU">
<description>Vesuv Application</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</
provider>
<jta-data-source>Postgres.postgres.vesuv</jta-data-source>
<class>
...
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="false" />
<property name="openjpa.jdbc.Schema" value="vesuv" />
</properties>
</persistence-unit>
</persistence>
Lookup of the SessionBean works. Invoking the method is fine.
SQL-Statements are done. But
LOG:
[DEBUG] [BenutzerManagerImpl] >> Mandant: Mandant:Vesuv
Servicestelle Id:1
Kurzname: SS PersonFK:0 Tstaend:null
13:18:31,644 INFO [Transaction] TX Required: Committing transaction
[EMAIL PROTECTED]
13:18:31,693 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt
31310826
UPDATE vesuv.v_org_einheit
...
13:18:31,702 DEBUG [SQL] <t 15431769, conn 0> [9 ms] spent
13:18:31,717 DEBUG [SQL] <t 15431769, conn 0> executing prepstmnt
23410971
UPDATE vesuv.benutzer SET
...
...
Caused by: <openjpa-1.0.1-r420667:592145 nonfatal store error>
org.apache.openjpa.util.StoreException: FEHLER: kann eine Sicht nicht
aktualisieren {prepstmnt 31310826 UPDATE vesuv.v_org_einheit SET
beziehung_org_einheit_typ = ?, kurz_name = ?, name = ?,
org_einheit_typ =
?, person_fk = ?, rechtsform = ?, tstaend = ?,
beziehung_org_einheit_fk =
?, uebergeordnete_org_einheit_fk = ? WHERE id = ? [params=(null) null,
(String) SS, (String) Vesuv Servicestelle, (String) SS, (long) 1,
(String)
SS, (Timestamp) 2008-05-26 10:10:43.96, (null) null, (null) null,
(long)
1]} [code=0, state=0A000]
FailedObject:
...
The LOG-File is in German, therefore some translation: Sicht = View.
The
Update of the View-PAO does not work. Any suggestions ???
Thanx Josef
BGS Beratungsgesellschaft
Software Systemplanung AG Niederlassung Rhein/Main
Robert-Koch-Straße 41
55129 Mainz
Fon: +49 (0) 6131 / 914-0
Fax: +49 (0) 6131 / 914-400
www.bgs-ag.de Geschäftssitz Mainz
Registergericht
Amtsgericht Mainz
HRB 62 50
Aufsichtsratsvorsitzender
Dr. Wolfgang Trommer
Vorstand
Hanspeter Gau
Hermann Kiefer
Nils Manegold
Heinz-Jörg Zimmermann