I guess it is the non jta database auto setting, can you duplicate your datasource set JtaManaged = false in the copies and set them on non-jta-datasource in both persistence units?
Romain Manni-Bucau @rmannibucau <https://twitter.com/rmannibucau> | Blog <http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> | LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber <http://www.tomitribe.com> 2016-01-11 12:42 GMT+01:00 tschuler <[email protected]>: > Hi Romain! > > The wrong database connection usage only happens if both persistence units > are injected into a session bean. > It does not matter if jta or non-jta data sources are used. > Attached catalina log catalina.log > <http://tomee-openejb.979440.n4.nabble.com/file/n4677401/catalina.log> > including stack trace. > > Digging deeper into the problem I can see that setting the persistence unit > property openjpa.jdbc.SchemaFactory is needed for provocating the problem: > > <persistence-unit name="my-unit1"> > <jta-data-source>myDatabase1</jta-data-source> > <properties> > *<property name="openjpa.jdbc.SchemaFactory" > value="native(ForeignKeys=true)" />* > </properties> > </persistence-unit> > <persistence-unit name="my-unit2"> > <jta-data-source>myDatabase2</jta-data-source> > <properties> > *<property name="openjpa.jdbc.SchemaFactory" > value="native(ForeignKeys=true)" />* > </properties> > </persistence-unit> > > Sorry for providing incomplete information at first. > > Can anyone explain why setting the property causes usage of wrong database > connection for the second entity manager? > > Best regards, > Thomas > > > > -- > View this message in context: > http://tomee-openejb.979440.n4.nabble.com/Multiple-EntityManager-using-wrong-Oracle-DataSource-tp4677399p4677401.html > Sent from the TomEE Dev mailing list archive at Nabble.com. >
