JDev Exception:Cannot acquire data source java:/app/jdbc/jdbc/DataSourceName.

本文介绍了解决在使用EclipseLink作为JPA提供者时,在WebLogic服务器上遇到的数据源配置错误问题。包括如何正确配置应用程序范围内的数据源以及使用全局数据源的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Issue:

When you are invoking some operation that related to EJB entity persistence in weblogic using EclipseLink, you may come across the exception as following.

Caused by: Exception EclipseLink-7060 (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence
.exceptions.ValidationException
Exception Description: Cannot acquire data source java:/app/jdbc/jdbc/DataSourceName.
Internal Exception: javax.naming.NameNotFoundException: While trying to look up /app/jdbc/jdbc/DatabaseDevDS in /app/ejb/E
JB.jar#SessionEJB.; remaining name '/app/jdbc/jdbc/DataSourceName'
at org.eclipse.persistence.exceptions.ValidationException.cannotAcquireDataSource(ValidationException.java:429)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:164)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:32
4)

Solution:

Please check whether your JNDI name format is like java:/app/jdbc/jdbc/DataSourceName*)

There is a double "jdbc") as opposed to a global name (*DataSourceName*) in your JPA persistence.xml. It indicates that you are using an “application scoped” datasource and not a “globally scoped” datasource that is defined directly on your WebLogic server.


If you want to use an application scoped datasource on Oracle WebLogic server, please refer to

http://wiki.eclipse.org/EclipseLink/Examples/JPA/WLS_AppScoped_DataSource

and

http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Application_Scoped_Datasource_Setup

The above enterprise application based tutorial using EclipseLink as the JPA provider describes a workaround for using an “application scoped” datasource when deployed on WebLogic 10.3 using both the normal <jta-data-source></jta-data-source>element and the overriding javax.persistence.jtaDataSource property, until the base WLS Server bug being tracked by EclipseLink bug# 246126 in http://bugs.eclipse.org/246126 is fixed shortly.

In addition, you’d better add following property to your persistence.xml:
1) Add a reference to the WebLogic platform
<property value="WebLogic_10" name="eclipselink.target-server"></property>

2) Verify that you have really defined your application scoped datasource with a double "jdbc" "java:/app/jdbc/jdbc/DatabaseDevDS"and didn't really mean "java:/app/jdbc/DatabaseDevDS" which is usually standard

see
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Persistence.xml
and an EclipseLink open source example that uses a globally define datasource in a WebLogic Web application tutorial using EclipseLink as the JPA provider
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/ejbModule/META-INF/persistence.xml

Also, an additional workaround would be to globally define the datasource on your integrated WebLogic server and reference it as described in...
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#Global_Scoped_Datasource_Setup

For the details, please refer to http://forums.oracle.com/forums/thread.jspa?threadID=828586

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值