exception with dynamic class loading [message #39272] |
Thu, 03 November 2005 23:13 |
Eclipse User |
|
|
|
Originally posted by: markjcarman.gmail.com
Hi,
I got a ClassNotFoundException when running the profiler on code
containing dynamic invocation of classes from external jar files, (see
stacktrace below).
The same code runs fine under both run and debug perspectives.
Adding the jar file containing the class to the build path fixed the
problem.
Is this a known bug?
Yours,
Mark
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
|
|
|
|
Re: exception with dynamic class loading [message #39366 is a reply to message #39335] |
Fri, 04 November 2005 09:45 |
Eclipse User |
|
|
|
Originally posted by: markjcarman.gmail.com
Hi Ali,
Yes I am profiling the code as a straight "java application".
I use dynamic class loading to load a particular JDBC driver (see code
below) based on values from a properties file.
The jars containing the particular drivers (from the different database
vendors) are in the runtime classpath (not the build-path).
The code runs fine under run and debug configurations, but under the
profile configuration it returns a ClassDefNotFound exception for the
driver implementation.
When I put the jar files containing the jdbc drivers into the build path,
the profiler runs without raising an exception.
Thanks for your help,
Mark
// load the database connection properties from a file
FileInputStream in = new FileInputStream(filename);
Properties dbProps = new Properties();
dbProps.load(in);
in.close();
// start database connection ....
Class.forName(dbProps.getProperty("jdbcDriver"));
Connection con =
DriverManager.getConnection(dbProps.getProperty("dbURL"));
|
|
|
Powered by
FUDForum. Page generated in 0.24888 seconds