[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Oracle Driver loaded from wrong classloader in OSGi environment sometimes
|
On Tue, 31 Mar 2009 15:31:34 +0200, Shaun Smith <shaun.smith@xxxxxxxxxx>
wrote:
Hello Shaun,
I have a strange problem that once in a while the Oracle Driver is
loaded from the wrong classloader and EclipseLink cannot use it.
I am importing the oracle driver packages into my project and set the
EntityManagerFactory like this
properties.put(PersistenceUnitProperties.CLASSLOADER,
this.getClass().getClassLoader());
in a class that is in the same bundle as the oracle imports. This
works in 80% of the time. But sometimes (due to some race conditions I
assume) the classloader that was used by the oracle bundle to register
itself with the driver manager seems to be the wrong one.
Passing a ClassLoader that can see the driver you're referencing
should always work. Internally there is an attempt to use the
DriverManager which fails in OSGi but then we try to load the class
using the provided ClassLoader. Are you getting an exception or just
seeing a log message? In EclipseLink 1.1 the log level of the message
indicating the DriverManager usage failure has been dropped lower so you
shouldn't see it at FINE anymore.
I am just seeing the "No driver found" as you can see below:
[EL Config]: 2009.04.07
13:06:03.786--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
access type for the persistent class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker]
is set to PROPERTY.
[EL Config]: 2009.04.07
13:06:03.866--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
alias name for the entity class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker]
is being defaulted to: LegacyPicker.
[EL Config]: 2009.04.07
13:06:04.006--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
access type for the persistent class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress]
is set to PROPERTY.
[EL Config]: 2009.04.07
13:06:04.006--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
alias name for the entity class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress]
is being defaulted to: OrderProgress.
[EL Config]: 2009.04.07
13:06:04.016--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
column name for element [float
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress.done]
is being defaulted to: DONE.
[EL Config]: 2009.04.07
13:06:04.076--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
column name for element [float
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress.shortfalls]
is being defaulted to: SHORTFALLS.
[EL Config]: 2009.04.07
13:06:04.076--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
access type for the persistent class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyPickOrder]
is set to PROPERTY.
[EL Config]: 2009.04.07
13:06:04.076--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
alias name for the entity class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyPickOrder]
is being defaulted to: LegacyPickOrder.
[EL Config]: 2009.04.07
13:06:04.216--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
access type for the persistent class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyOrderPosition]
is set to PROPERTY.
[EL Config]: 2009.04.07
13:06:04.317--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
alias name for the entity class [class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyOrderPosition]
is being defaulted to: LegacyOrderPosition.
[EL Config]: 2009.04.07
13:06:04.387--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
access type for the persistent class [class
de.topsystem.tks.demo.devices.core.internal.models.Voxter] is set to
PROPERTY.
[EL Config]: 2009.04.07
13:06:04.387--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
alias name for the entity class [class
de.topsystem.tks.demo.devices.core.internal.models.Voxter] is being
defaulted to: Voxter.
[EL Config]: 2009.04.07
13:06:04.387--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
column name for element [java.lang.String
de.topsystem.tks.demo.devices.core.internal.models.Voxter.id] is being
defaulted to: ID.
[EL Config]: 2009.04.07
13:06:04.397--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
target entity (reference) class for the many to one mapping element
[private
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker
de.topsystem.tks.demo.devices.core.internal.models.Voxter.assignedTo] is
being defaulted to: class
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker.
[EL Config]: 2009.04.07
13:06:04.497--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
primary key column name for the mapping element [private
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker
de.topsystem.tks.demo.devices.core.internal.models.Voxter.assignedTo] is
being defaulted to: benutzer_id.
[EL Config]: 2009.04.07
13:06:04.497--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
target entity (reference) class for the one to one mapping element
[private
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyPickOrder.progress]
is being defaulted to: class
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress.
[EL Config]: 2009.04.07
13:06:04.537--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
primary key column name for the mapping element [private
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.OrderProgress
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyPickOrder.progress]
is being defaulted to: auf_nr.
[EL Config]: 2009.04.07
13:06:04.537--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
target entity (reference) class for the many to one mapping element
[de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyOrderPosition.pickedBy]
is being defaulted to: class
de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker.
[EL Config]: 2009.04.07
13:06:04.537--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--The
primary key column name for the mapping element
[de.topsystem.tks.demo.legacy.warehouse.core.models.pickers.LegacyPicker
de.topsystem.tks.demo.legacy.warehouse.core.models.orders.LegacyOrderPosition.pickedBy]
is being defaulted to: benutzer_id.
[EL Info]: 2009.04.07
13:06:06.159--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--EclipseLink,
version: Eclipse Persistence Services - 1.0.1 (Build 20080905)
[EL Config]: 2009.04.07
13:06:06.289--ServerSession(18779484)--Connection(7339988)--Thread(Thread[Worker-0,5,main])--connecting(DatabaseLogin(
platform=>OraclePlatform
user name=> "topradio"
datasource URL=> "jdbc:oracle:thin:@topspeechdemo:1521:xe"
))
[EL Warning]: 2009.04.07
13:06:06.319--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--java.sql.SQLException:
No suitable driver
[EL Severe]: 2009.04.07
13:06:10.596--ServerSession(18779484)--Thread(Thread[Worker-0,5,main])--Local
Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0.1 (Build
20080905)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver
Error Code: 0
at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:313)
at
org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:308)
at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:136)
at
org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:164)
at
org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:324)
at
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:264)
at
org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:407)
at
org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:130)
at
org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:367)
at
org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:500)
at
org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:606)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:211)
at
org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:246)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:69)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:118)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:112)
at
org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:100)
at
de.topsystem.tks.demo.legacy.persistence.internal.Startup.createEntityManagerFactory(Startup.java:36)
at
de.topsystem.tks.demo.legacy.persistence.internal.Startup$1.run(Startup.java:67)
at
de.topsystem.tks.demo.legacy.persistence.internal.Startup$2.run(Startup.java:86)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at
org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:97)
... 18 more
Not only is the error message missleading, its also not understandable why
it happens. The error message should be "Invalid class loader" and it
should also print out which bundles classloader was used to create the
driver and to access it. I know using the Sun Driver Manager thats not
possible. But anyway, EclipseLink should do better.
You can "instanceof BundleReference" the class-loader of the driver
yourself and give an appropriate error message when the SUN driver manager
throws its "No suitable driver" exception. Or better yet, check *before*
you access the driver manager if the driver can be loaded from the
Persistence Providers classmanager.
As I said this happens not every time, but 4 out of 10 starts the
applications fails to "find" the driver (class loader problem). Those
failures always happen in a row. Like 4 starts its ok... then 4 not
working, 8th start working again.
I am using org.eclipse.persistence.jpa.osgi.PersistenceProvider.
Anyway it would be better this whole old DriverManager thing would be
replaced by proper OSGi services. The Oracle driver would just
register itself as a driver in the OSGi system. Dreams :)
Dreams can come true! ;-) There is an OSGi specification coming for
obtaining JDBC Drivers which should make life easier for everyone--I'm
definitely looking forward to it.
Lets hope! :) I will be the first to test it out :)
Thanks for your efforts!
Phil