You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by daedalus <M....@EUROKEY.de> on 2013/11/12 15:48:17 UTC

TomEE uses wrong DataSource for JPA

Hallo, 

I'm using a single TomEE instance to deploy 2 Webapplications. Both
applications use a different database and different Entities. 

I have both DataSources configured in the tomee.xml like this: 

In Application 1 I use this persistence.xml 

In Application 2 I use this persistence.xml 


This is correct or? Now both Application should use a different databases
or?


However it is not the case. Both Applications use the same database
connection (jdbc/DB1). Why is that the case? Have I found a very serious bug
or did I do something wrong with the configuration? 





--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-uses-wrong-DataSource-for-JPA-tp4666124.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE uses wrong DataSource for JPA

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

never tested with tomcat datasources but with tomee datasources it
works very well on 1.6.0 and 1.5.1 (never used 1.5.2)
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/11/15 daedalus <M....@eurokey.de>:
> Sorry of course the typos are not intended. I changed them to not spoil
> projects names and made the typos.
>
> I use the id "jdbc/Db1" and "jdbc/Db2" in tomee.xml and of course I use the
> same values in my persistence.xml as names of jta datasources.
>
> To inject the PersistenceManager I use @PersistenceContext("DB1_PU") and
> @PersistenceContext("DB2_PU"),
> the same values as the name of the persistence units in the persistence.xml
>
> Now we have also the case that we have a single application with two
> datasources. Sometimes the correct datasource is used and sometimes not.
>
> Have you ever testes tomcat with multiples datasources and jpa? I still
> think there is something wrong.
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/TomEE-uses-wrong-DataSource-for-JPA-tp4666124p4666185.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE uses wrong DataSource for JPA

Posted by daedalus <M....@EUROKEY.de>.
Sorry of course the typos are not intended. I changed them to not spoil
projects names and made the typos. 

I use the id "jdbc/Db1" and "jdbc/Db2" in tomee.xml and of course I use the
same values in my persistence.xml as names of jta datasources. 

To inject the PersistenceManager I use @PersistenceContext("DB1_PU") and
@PersistenceContext("DB2_PU"),
the same values as the name of the persistence units in the persistence.xml

Now we have also the case that we have a single application with two
datasources. Sometimes the correct datasource is used and sometimes not. 

Have you ever testes tomcat with multiples datasources and jpa? I still
think there is something wrong. 






--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-uses-wrong-DataSource-for-JPA-tp4666124p4666185.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: TomEE uses wrong DataSource for JPA

Posted by Romain Manni-Bucau <rm...@gmail.com>.
seems you have several typo in id and jta-data-source, is it intended?
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2013/11/12 daedalus <M....@eurokey.de>:
> Hallo,
>
> I'm using a single TomEE instance to deploy 2 Webapplications. Both
> applications use a different database and different Entities.
>
> I have both DataSources configured in the tomee.xml like this:
>
> In Application 1 I use this persistence.xml
>
> In Application 2 I use this persistence.xml
>
>
> This is correct or? Now both Application should use a different databases
> or?
>
>
> However it is not the case. Both Applications use the same database
> connection (jdbc/DB1). Why is that the case? Have I found a very serious bug
> or did I do something wrong with the configuration?
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/TomEE-uses-wrong-DataSource-for-JPA-tp4666124.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.