Configure openejb autoconfig by Tomee with multiple datasources and miltiple apppication

641 views Asked by At

We use Tomee 1.7.1 jaxrs with multiple datasources and applications. For example:

App1 persistance.xml

<persistence-unit name="DS1_PU" transaction-type="JTA">
    <jta-data-source>DS1</jta-data-source>
...
</persistence-unit>

App2 persistance.xml

<persistence-unit name="DS2_PU" transaction-type="JTA">
    <jta-data-source>DS2</jta-data-source>
...
</persistence-unit>

tomee.xml

<Resource id="DS1" type="DataSource">
    JdbcDriver  org.postgresql.Driver
    JdbcUrl     jdbc:postgresql://localhost:5432/DS1
    UserName    postgres
    Password    123
    JtaManaged  true
    ValidationQuery select 1
    TestOnBorrow    true        
</Resource>

<Resource id="DS2" type="DataSource">
    JdbcDriver  org.postgresql.Driver
    JdbcUrl     jdbc:postgresql://localhost:5432/DS2
    UserName    postgres
    Password    123
    JtaManaged  true
    ValidationQuery select 1
    TestOnBorrow    true        
</Resource>

Deployment log:

INFORMATION: Adjusting PersistenceUnit DS1_PU to Resource ID 'DS1NonJta' from 'null' INFORMATION: Adjusting PersistenceUnit DS2_PU to Resource ID 'DS2NonJta' from 'null'

Problem: When I make a typo in a persistance.xml, f.e.

<persistence-unit name="DS2_PU" transaction-type="JTA">
    <jta-data-source>DS_WRONG</jta-data-source>
...
</persistence-unit>

app still deployes but use wrong data source:

INFORMATION: Adjusting PersistenceUnit DS2_PU to Resource ID 'DS1NonJta' from 'null'

It seems that openejb takes first founded data source. Can I disable this "feature"?

0

There are 0 answers