Skip to main content

[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, 07 Apr 2009 18:43:29 +0200, Shaun Smith <shaun.smith@xxxxxxxxxx> wrote:

Hi Philipp,

Philipp Kursawe wrote:
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.
This is standard OSGi stuff.  If you try to load a resource or class
with a classloader that doesn't have visibility to that resource or
class it won't be found.  If you're providing a classloader that can't
see the driver you want then you get an error saying EclipseLink can't
find the driver.  Seems reasonable.

To further support my claim, that the wrong classloader is used:
I am importing those packages from the bundle that creates the EntityManagerFactory
 oracle.jdbc;version="10.2.0.2",
 oracle.jdbc.connector;version="10.2.0.2",
 oracle.jdbc.driver;version="10.2.0.2",

and create the EMF like this:
properties.put(PersistenceUnitProperties.CLASSLOADER, this.getClass().getClassLoader()); EntityManagerFactory emf = new PersistenceProvider().createEntityManagerFactory("demo-pu", properties);

It sometimes works and sometimes (like just now) it does not.


Regards,
Phil



Back to the top