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

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 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

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

你可能感兴趣的:(java,exception,weblogic,jpa,application,reference)