I'm not sure how you get variable behavior from the code since the code
path is always the same, however you can also get a "no suitable
driver" when you do actually find the driver but the database
connection doesn't work. This is definitely misleading but I have seen
it happen when I haven't started Oracle XE and attempt to run a
program. Are you sure that your database is always available? Perhaps
you're out of connections when you attempt to connect sometimes?
Shaun
Philipp Kursawe wrote:
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
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--
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
Oracle is committed to developing practices and products that
help protect the environment
|