On Dec 5, 2006, at 12:22 AM, Per Newgro wrote:

He noticed me to add the following lines to my ejb-jar.xml file
      <session>
         ...
            <resource-ref>
                <res-ref-name>APPLDB</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
            <resource-ref>
                <res-ref-name>APPLDBnoTx</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
      </session>

One of his comments was:
 On a slightly different note, I'm curious why you'd have two
 connectors with the exact same configuration

To answer David's question, the first data source is connected to JTA and therefore the setAutocommit and commit methods shouldn't be called. The second data source is a not connected to JTA and is using resource local transactions.

And now i have my problem with exactly this issue. Access to the APPLDB is working by lookup("java:comp/env/APPLDB"). But if i try to access the no
transaction datasource by lookup("java:comp/env/APPLDBnoTx") i get a
javax.naming.NameNotFoundException: Name "java:comp/env/APPLDBnoTx" not found.

I'm not sure on the details of how you do this with OpenEJB, but you'll need to declare another database connector and map your resource-ref to that connector. Hopefully, David or someone else will fill in the details :)

Is there an issue in ejb spec that i cant access same database by usage of
different datasources?

Nope.  What you are doing is perfectly legal and quite common.

-dain

Reply via email to