Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

howto use JNDI datasource with TopLink JPA in a SE environment (tomcat 5)?

567350Jun 13 2007 — edited Nov 23 2008
Hi,

we are using TopLink JPA for webapps running on Tomcat 5.5 in a Java SE environment. We have the requirement to use the connection pool provided by tomcat, which provides the datasource via JNDI to the application.

If I configure a "non-jta-datasource" in persistence.xml:

<persistence-unit name="plc_webPU" transaction-type="RESOURCE_LOCAL">
<provider>
oracle.toplink.essentials.PersistenceProvider
</provider>
<non-jta-data-source>jdbc/DatasourceTest</non-jta-data-source>
...classes list ...
</persistence-unit>

we always the the following error:

Caused by: Exception [TOPLINK-7060] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: Cannot acquire data source [jdbc/DatasourceTest].
Internal Exception: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at oracle.toplink.essentials.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:358)
at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:120)
at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:170)
at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:537)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:212)
... 55 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:121)
at javax.naming.InitialContext.lookup(InitialContext.java:355)
at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:114)
... 59 more

Accessing the datasource from a simple test-jsp page and issuing a query against the database works, so the datasource is bound to JNDI.

Is there any error in our configuration of persistence xml???

regards,
hans
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2008
Added on Jun 13 2007
16 comments
30,905 views