Hi, just tried and seems fine (well used hsqldb instead of h2 but think it is not the issue).
Is there any "Adjusting PersistenceUnit u1 <jta-data-source>" lines in the logs? *Romain Manni-Bucau* *Twitter: @rmannibucau <https://twitter.com/rmannibucau>* *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau* *Github: https://github.com/rmannibucau* 2012/11/9 diuis <di...@yahoo.it> > Hi to all. > > My TomEE JavaEE 6 web application needs two different jpa persistence > units: > the first uses a H2 stand alone database, the other uses a MySQL database. > All seems ok, but when I use the two persistence units (and so the two > databases) in the same transaction, I guess that something fails. > Sometimes, the TomEE connection pool, or the JPA implementation (OpenJPA in > my case), uses the same database (ever H2) for both connections. > > For example this is the log of my businness operation that use the two > persistence units: > > Nov 09, 2012 5:22:25 PM com.bravofly.indexer.scheduler.web.IndexerBean > index > INFO: start manual index > Nov 09, 2012 5:22:25 PM > org.apache.openjpa.lib.log.CommonsLogFactory$LogAdapter info > INFO: Starting OpenJPA 2.2.0 > Nov 09, 2012 5:22:25 PM > org.apache.openjpa.lib.log.CommonsLogFactory$LogAdapter info > INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.H2Dictionary" (H2 > 1.3.169 (2012-09-09) ,H2 JDBC Driver 1.3.169 (2012-09-09)). > Nov 09, 2012 5:22:25 PM > com.bravofly.indexer.scheduler.facade.BookingIndexerFacadeImpl > indexAllBookings > INFO: start indexing (from last update time 11:37:20 AM CEST)... > Nov 09, 2012 5:22:25 PM > org.apache.openjpa.lib.log.CommonsLogFactory$LogAdapter info > INFO: Starting OpenJPA 2.2.0 > Nov 09, 2012 5:22:25 PM > org.apache.openjpa.lib.log.CommonsLogFactory$LogAdapter info > INFO: Using dictionary class "org.apache.openjpa.jdbc.sql.H2Dictionary" (H2 > 1.3.169 (2012-09-09) ,H2 JDBC Driver 1.3.169 (2012-09-09)). > Nov 09, 2012 5:22:26 PM > com.bravofly.indexer.scheduler.facade.BookingIndexerFacadeImpl index > SEVERE: indexing failed > javax.ejb.EJBTransactionRolledbackException: The transaction has been > marked > rollback only because the bean encountered a non-application exception > :org.apache.openjpa.persistence.PersistenceException : Table > "BOOKING_AUDIT" > not found; SQL statement: > SELECT t0.ID_BOOKING, t0.CREATION_DATE, t0.LAST_UPDATE, t0.STATUS FROM > BOOKING_AUDIT t0 WHERE (t0.LAST_UPDATE > ?) [42102-169] {SELECT > t0.ID_BOOKING, t0.CREATION_DATE, t0.LAST_UPDATE, t0.STATUS FROM > BOOKING_AUDIT t0 WHERE (t0.LAST_UPDATE > ?)} [code=42102, state=42S02] > at > > org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:345) > at > > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:283) > at $Proxy87.getLastUpdatedBookings(Unknown Source) > > JPA is using only one dialect, H2, and I guess, only one db: BOOKING_AUDIT > is a table of the other db, MySql. > > 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="pu2" transaction-type="JTA"> > <jta-data-source>jdbc/volagratis</jta-data-source> > <mapping-file>META-INF/orm2.xml</mapping-file> > > <class>com.bravofly.indexer.scheduler.model.BookingAudit</class> > > <class>com.bravofly.indexer.scheduler.model.BookingIdToIndex</class> > <exclude-unlisted-classes>true</exclude-unlisted-classes> > <properties> > > <property name="openjpa.Log" value="commons" /> > <property name="openjpa.DataCache" > value="true(EnableStatistics=true)"/> > <property name="openjpa.QueryCache" > value="true(CacheSize=1000, > SoftReferenceSize=100)"/> > <property > name="openjpa.ConnectionFactoryProperties" > value="PrettyPrint=true, PrintParameters=True"/> > </properties> > </persistence-unit> > > <persistence-unit name="pu1" transaction-type="JTA"> > <jta-data-source>jdbc/indexer</jta-data-source> > <mapping-file>META-INF/orm1.xml</mapping-file> > > <class>com.bravofly.indexer.scheduler.model.LastUpdateTime</class> > <exclude-unlisted-classes>true</exclude-unlisted-classes> > <properties> > > <property name="openjpa.Log" value="commons" /> > <property name="openjpa.DataCache" > value="true(EnableStatistics=true)"/> > <property name="openjpa.QueryCache" > value="true(CacheSize=1000, > SoftReferenceSize=100)"/> > <property > name="openjpa.ConnectionFactoryProperties" > value="PrettyPrint=true, PrintParameters=True"/> > </properties> > </persistence-unit> > > </persistence> > > Any idea? > Demis Gallisto > > > > -- > View this message in context: > http://openejb.979440.n4.nabble.com/TomEE-1-5-1-SNAPSHOT-strange-JPA-behavior-tp4658500.html > Sent from the OpenEJB User mailing list archive at Nabble.com. >