yep just a kind of template don't worry does the jta and non jta datasource use the same real database?
- Romain 2012/6/27 Stevo Slavić <[email protected]> > Tried. > > 13:22:58.892 [main] INFO OpenEJB.startup.config - Configuring > PersistenceUnit(name=a_foo) > 13:22:58.893 [main] INFO OpenEJB.startup.config - Auto-creating a Resource > with id 'jdbc/acme_fooNonJta' of type 'DataSource for 'a_foo'. > 13:22:58.893 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_fooNonJta, type=Resource, provider-id=jdbc/acme_foo) > 13:22:58.893 [main] INFO OpenEJB.startup.config - Adjusting > PersistenceUnit a_foo <non-jta-data-source> to Resource ID > 'jdbc/acme_fooNonJta' from 'null' > 13:22:58.893 [main] INFO OpenEJB.startup.config - Configuring > PersistenceUnit(name=a_bar) > 13:22:58.894 [main] INFO OpenEJB.startup.config - Auto-creating a Resource > with id 'jdbc/acme_barNonJta' of type 'DataSource for 'a_bar'. > 13:22:58.894 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_barNonJta, type=Resource, provider-id=jdbc/acme_bar) > 13:22:58.894 [main] INFO OpenEJB.startup.config - Adjusting > PersistenceUnit a_bar <non-jta-data-source> to Resource ID > 'jdbc/acme_barNonJta' from 'null' > > It seems to have cleaned up wiring persistence unit to data source but > tests still fail with same infamous "user lacks privileges..." error. As if > connection/database is not actually there when schema is about to be > created. > Persistence unit references only jta data source. I wonder why are only > unmanaged non-jta data sources mentioned in openejb logs. And if I > understand logs well, only unmanaged sources are created and "wired" to > persistence units. > > It didn't help adding > "<non-jta-data-source>jdbc/acme_fooNonJta</non-jta-data-source>" and > "<non-jta-data-source>jdbc/acme_barNonJta</non-jta-data-source>" to > persistence.xml > > Logs after adding non-jta-data-source look like > > 13:58:32.299 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_bar, type=Resource, provider-id=Default JDBC Database) > 13:58:32.300 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_foo, type=Resource, provider-id=Default JDBC Database) > ... > 13:58:33.408 [main] INFO OpenEJB.startup.config - Configuring > PersistenceUnit(name=a_foo) > 13:58:33.409 [main] INFO OpenEJB.startup.config - Auto-creating a Resource > with id 'jdbc/acme_fooNonJta' of type 'DataSource for 'a_foo'. > 13:58:33.409 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_fooNonJta, type=Resource, provider-id=jdbc/acme_foo) > 13:58:33.409 [main] INFO OpenEJB.startup.config - Configuring > PersistenceUnit(name=a_bar) > 13:58:33.410 [main] INFO OpenEJB.startup.config - Auto-creating a Resource > with id 'jdbc/acme_barNonJta' of type 'DataSource for 'a_bar'. > 13:58:33.410 [main] INFO OpenEJB.startup.config - Configuring > Service(id=jdbc/acme_barNonJta, type=Resource, provider-id=jdbc/acme_bar) > ... > > I don't understand there "provider-id=Default JDBC Database". I guess it's > some sort of shared parent template datasource/metadata. > > Kind regards, > Stevo Slavić. > > On Wed, Jun 27, 2012 at 1:20 PM, Romain Manni-Bucau > <[email protected]>wrote: > > > Hi, > > > > can you try removing java: in persistence.xml? > > > > > > - Romain > > > > > > 2012/6/27 Stevo Slavić <[email protected]> > > > > > Hello OpenEJB community, > > > > > > I'm migrating a legacy system to Java EE 6 and JBoss AS 7.1.1 > > > With the upgrade came "updated" JBoss AS 7.1.1 provided CXF version > > > (2.4.6). This broke and revealed all yet rare openejb tests. Then I > > > upgraded openejb too, from 3.1.4 to 4.0.0 but not all tests are > passing. > > > To be more specific there is 1 passing, and 2 failing tests, all in > same > > > module using shared jndi.properties, persistence.xml, and ejb-jar.xml > > > In jndi.properties (see [1]) two data sources are configured for > openejb > > to > > > create. > > > In persistence.xml there are two persistence units. Each PU references > a > > > single data source. > > > > > > Test that passes, has EntityManager instance injected > > > (@PersistenceContext(name="a_bar", unitName="a_bar" )) and successfully > > > executes queries, like select on Entity2. > > > Tests that fail, fail late, when createQuery is issued on other > injected > > > EntityManager instance (@PersistenceContext(name="a_foo", > > > unitName="a_foo")) - HSLQDB reports "user lacks privilege or object not > > > found: PUBLIC.ENTITY2 {stmnt 1836093446 ALTER TABLE ENTITY2 ADD COLUMN > ID > > > NUMERIC} [code=-5501, state=42501]" > > > > > > There seems to be an issue with schema creation. To fail earlier, I > > > uncomment configuring openjpa.InitializeEagerly to true. > > > > > > Then in openejb log output I noticed openejb is doing some unwanted > stuff > > > with data sources (see [3]), associating wrong data sources with > > > persistence units, and creating non-jta data sources which aren't > > > needed/referenced. > > > > > > It smells to me that some openejb convention is not followed well. > Maybe > > > it's just HSQLDB configuration (2.2.4 is referenced by openejb, but I > > also > > > tried with 2.2.8). > > > > > > I did my "homework", found lots of entries online about "user lacks > > > privilege or object not found" and configuring openejb, but neither of > > them > > > helped. > > > > > > Does anyone see what could be wrong here? > > > > > > I'd like to preserve persistence.xml as-is, while jndi.properties can > be > > > changed or even replaced entirely with openejb.xml if needed. > > > > > > Kind regards, > > > Stevo Slavić. > > > > > > > > > [1] jndi.properties > > > > > > > > > > > > java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory > > > openejb.embedded.remotable=true > > > openejb.altdd.prefix=test. > > > > > > jdbc/acme_foo=new://Resource?type=DataSource > > > jdbc/acme_foo.JdbcUrl=jdbc:hsqldb:mem:acme_foo > > > jdbc/acme_foo.JdbcDriver=org.hsqldb.jdbcDriver > > > jdbc/acme_foo.Username=sa > > > jdbc/acme_foo.Password= > > > jdbc/acme_foo.JtaManaged=true > > > > > > jdbc/acme_bar=new://Resource?type=DataSource > > > jdbc/acme_bar.JdbcUrl=jdbc:hsqldb:mem:acme_bar > > > jdbc/acme_bar.JdbcDriver=org.hsqldb.jdbcDriver > > > jdbc/acme_bar.Username=sa > > > jdbc/acme_bar.Password= > > > jdbc/acme_bar.JtaManaged=true > > > > > > > > > [2] 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="a_foo" transaction-type="JTA"> > > > <jta-data-source>java:jdbc/acme_foo</jta-data-source> > > > > > > <class>a.foo.model.Entity1</class> > > > <exclude-unlisted-classes>true</exclude-unlisted-classes> > > > > > > <properties> > > > <property name="hibernate.dialect" > > > value="org.hibernate.dialect.Oracle10gDialect"/> > > > <property name="hibernate.show_sql" value="true"/> > > > <property name="hibernate.transaction.manager_lookup_class" > > > > > > value="org.hibernate.transaction.JBossTransactionManagerLookup"/> > > > > > > <property name="openjpa.jdbc.SynchronizeMappings" > > > value="buildSchema(ForeignKeys=true)"/> > > > <!-- > > > <property name="openjpa.InitializeEagerly" value="true"/> > > > --> > > > </properties> > > > </persistence-unit> > > > > > > <persistence-unit name="a_bar" transaction-type="JTA"> > > > <jta-data-source>java:jdbc/acme_bar</jta-data-source> > > > > > > <class>a.bar.model.Entity2</class> > > > <exclude-unlisted-classes>true</exclude-unlisted-classes> > > > > > > <properties> > > > <property name="hibernate.dialect" > > > value="org.hibernate.dialect.Oracle10gDialect"/> > > > <property name="hibernate.show_sql" value="true"/> > > > <property name="hibernate.transaction.manager_lookup_class" > > > > > > value="org.hibernate.transaction.JBossTransactionManagerLookup"/> > > > > > > <property name="openjpa.jdbc.SynchronizeMappings" > > > value="buildSchema(ForeignKeys=true)"/> > > > <!-- > > > <property name="openjpa.InitializeEagerly" value="true"/> > > > --> > > > </properties> > > > </persistence-unit> > > > </persistence> > > > > > > > > > [3] openejb container startup log fragment > > > > > > 11:50:07.459 [main] INFO OpenEJB.startup.config - Configuring > > > PersistenceUnit(name=a_foo) > > > 11:50:07.462 [main] INFO OpenEJB.startup.config - Auto-creating a > > Resource > > > with id 'jdbc/acme_barNonJta' of type 'DataSource for 'a_foo'. > > > 11:50:07.462 [main] INFO OpenEJB.startup.config - Configuring > > > Service(id=jdbc/acme_barNonJta, type=Resource, > provider-id=jdbc/acme_bar) > > > 11:50:07.462 [main] INFO OpenEJB.startup.config - Adjusting > > > PersistenceUnit a_foo <jta-data-source> to Resource ID 'jdbc/acme_bar' > > from > > > 'java:jdbc/acme_foo' > > > 11:50:07.462 [main] INFO OpenEJB.startup.config - Adjusting > > > PersistenceUnit a_foo <non-jta-data-source> to Resource ID > > > 'jdbc/acme_barNonJta' from 'null' > > > 11:50:07.462 [main] INFO OpenEJB.startup.config - Configuring > > > PersistenceUnit(name=a_bar) > > > 11:50:07.463 [main] INFO OpenEJB.startup.config - Adjusting > > > PersistenceUnit a_bar <jta-data-source> to Resource ID 'jdbc/acme_bar' > > from > > > 'java:jdbc/acme_bar' > > > 11:50:07.463 [main] INFO OpenEJB.startup.config - Adjusting > > > PersistenceUnit a_bar <non-jta-data-source> to Resource ID > > > 'jdbc/acme_barNonJta' from 'null' > > > > > >
