[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] OracleDataSource and threading (?) problems
|
Try connecting to the data source directly (without using Eclipselink) and
running a simple query through it to verify if it works.
If it does verify that you are not passing invalid user/password (either in
persistence.xml or through properties)
----- Original Message -----
From: "David Parker" <david@xxxxxxxxxxxxxx>
To: "EclipseLink User Discussions" <eclipselink-users@xxxxxxxxxxx>
Sent: Monday, March 02, 2009 8:31 PM
Subject: Re: [eclipselink-users] OracleDataSource and threading (?) problems
Thank you very much for the informative response.
We have no kind of container at all - not even tomcat, so the DataSource
being used is just created by the application, then the various jdbc
parameters are set on it. Perhaps my problem is with the DataSource
config rather than with eclipselink? I suspect I am doing something
ignorant there.....
I am running with eclipselink 1.0.2, btw.
Originally I made the EntityManagerFactory a static, which was working
OK. I tried making it a local thinking that that was causing the
problems, but it didn't make any difference.
The code that creates the EntityManagerFactory looks like this:
protected EntityManagerFactory getEntityManagerFactory() {
if (emf == null || !emf.isOpen()) {
synchronized (emf_lock) {
if (emf == null) {
DataSource ds = getDataSource(emfProps);
HashMap newprop = new HashMap();
newprop.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, ds);
emf = Persistence.createEntityManagerFactory(puName,
newprop);
}
}
}
return emf;
}
The getDataSource is simple:
private DataSource getDataSource(Map<String, String> props) {
try {
OracleDataSource ds = new OracleDataSource();
//String driver = props.get(DBConstants.JPA_DRIVER_PROP);
String url = props.get(DBConstants.JPA_URL_PROP);
String user = props.get(DBConstants.JPA_USER_PROP);
String password = props.get(DBConstants.JPA_PASSWORD_PROP);
//ds.setDriverType(driver);
ds.setURL(url);
ds.setUser(user);
ds.setPassword(password);
return ds;
} catch (SQLException ex) {
System.err.println("getDataSoure failed");
return null;
}
}
Here is one of the stacks.
[EL Info]: 2009.02.26 16:23:40.526--UnitOfWork(803339)--Communication
failure detected when attempting to perform read query outside of a
transaction. Attempting to retry query.
java.lang.NullPointerException[EL Warning]: 2009.02.26 16:23:40.526--
UnitOfWork(1643286)--java.lang.NullPointerException
at org .eclipse .persistence
.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:
1219)
at org .eclipse .persistence
.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:
1162)
at org .eclipse .persistence .internal .indirection
.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:77)
at org .eclipse .persistence .internal .indirection
.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:67)
[EL Info]: 2009.02.26 16:23:40.528--UnitOfWork(803339)--Communication
failure detected when attempting to perform read query outside of a
transaction. Attempting to retry query.
at org .eclipse .persistence .internal
.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
at org .eclipse .persistence .internal .indirection
.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:161)
at org .eclipse .persistence .internal .indirection
.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:230)
at org .eclipse .persistence .internal
.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:83)
at org .eclipse
.persistence.indirection.IndirectMap.buildDelegate(IndirectMap.java:110)
at org .eclipse
.persistence.indirection.IndirectMap.getDelegate(IndirectMap.java:314)
at org.eclipse.persistence.indirection.IndirectMap.get(IndirectMap.java:
301)
On Mar 2, 2009, at 6:34 PM, Michael O'Brien wrote:
David,
Hi,
1) Yes, EclipseLink is able to run in both container-managed (JTA) and
application managed (RESOURCE_LOCAL) modes on any specific full JEE
container.
Also, using a datasource from Tomcat within an SE JPA application has
been tested.
Check that you are specifying the jta-data-source/non-jta-data- source
property and that you are ok with the fact that the transaction-type
defaults to JTA if not specified -when deployed to the server and
RESOURCE_LOCAL when on an SE client - this will affect whether the
datasource or db properties are used - if they are still specified.
For example, for details on setting up an Oracle datasource on
WebLogic see...
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial#JNDI_Datasource_Setup
Depending on the container that your datasource is running on - you
will need extra configuration steps. I assume that your datasource is
NOT application managed and that you are using a globally defined
datasource (no need for a deploy).
For example when targeting Tomcat, you will need to reference the
catalina and ds support jars, set your InitialContext factory and
prefixes, modify persistence.xml to use a non-jta-data-source and setup
the datasource on the server.
2) For the NPE's, post the stacktrace and we will advise.
Note: that the default behavior for picking up entities also changes
on/off the server and you may need to specify a combination of <class>
entries and/or <exclude-unlisted-classes> to pickup or fine tune which
entities are picked up.
If you would like examples of how to configure your application for a
specific server, you may refer to the following examples by server.
Most of the examples are using an Oracle JTA datasource.
http://wiki.eclipse.org/EclipseLink/Examples/JPA#JPA_Web_Application_Tutorials
There are specific instructions for running an application managed
datasource for WebLogic
http://wiki.eclipse.org/EclipseLink/Examples/JPA/WLS_AppScoped_DataSource
and in your particular situation, an example SE JPA app that uses the
JTA datasource on Tomcat 6.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Using_JNDI_outside_the_Tomcat_container_for_J2SE_Applications
For reference here is a RESOURCE_LOCAL SE JPA app that does not use a
datasource.
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.common.ddlgen/
Also, be aware that Catalina based server will require a
SessionCustomizer that modifies the lookupType on the connector to a
String type, see..
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Session_Customizer
If you post a copy of your persistence.xml as well as your overriding
properties and the stack trace/log we will triage this issue.
- config details (Application server, Database, EclipseLink version)
part of persistence.xml and the logs
- persistence.xml
- property overrides
- application managed *-oracle-ds.xml datasource definition
- globally defined datasource definition
- stacktrace
- some specific example client code if you can (especially if your
client is multi-threaded)
- EclipseLink [EL] logs on FINEST if possible (both Client and Server
if possible)
thank you
/michael
David Parker wrote:
We are using eclipselink in a server application, but there is no
container (j2ee, spring, etc) involved: our persistence environment is
completely application-managed.
The server has a single static EntityManagerFactory, and each serve
thread gets its own EntityManager.
This was all working fine when we were passing the low-level jdbc
properties (driver, url, user, password) in the map to create the
EntityManager, but we started having problems
when we tried to switch to using an OracleDataSource (we want to be
able to take advantage of Oracle RAC eventually).
The code now creates an EntityManager with a single item in the
property map, a pre-constructed DataSource object.
Unfortunately, we are now seeing random NPE's from deep in the
eclipselink stack. It has all the earmarks of a threading problem, but
all that has changed is the use of the DataSource.
Is DataSource usage fully supported in a non-containter environment?
Are there additional configuration steps that need to be taken. Is
anybody using OracleDataSource with eclipselink?
Thanks in advance for any clues.
===========================================
David Parker
david@xxxxxxxxxxxxxx
(401) 263-1782
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
===========================================
David Parker
david@xxxxxxxxxxxxxx
(401) 263-1782
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users