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

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.
You can "instanceof BundleReference" the class-loader of the driver yourself.
But how do we know what bundle the driver is in?
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.
We first attempt to use the driver manager (this code is common in OSGi and SE/EE).  If that fails we try the classloader associated with the persistence unit.  If that fails we throw an exception--we're out of options.  In previous releases we logged an error message when the driver manager attempt failed.  This was confusing because then we found it with the persistence unit classloader.  As of 1.1 (I think it was 1.1) we don't log the first failure unless logging is turned way up.

    Shaun

--
Oracle
Shaun Smith | Principal Product Manager
Phone: ++19055023094 | |
Oracle Oracle Server Technologies, Oracle TopLink
ORACLE Canada | 110 Matheson Boulevard West, Suite 100, Mississauga, Ontario | L5R 3P4

Green Oracle Oracle is committed to developing practices and products that help protect the environment

Back to the top