Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Test and Performance Tools Platform (TPTP) » exception with dynamic class loading
exception with dynamic class loading [message #39272] Thu, 03 November 2005 23:13 Go to next message
Eclipse UserFriend
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 #39335 is a reply to message #39272] Fri, 04 November 2005 03:28 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 404
Registered: July 2009
Senior Member
Hello Mark,

How were you profiling your application? As a "Java Application" (i.e. A
java project in your workspace) or as an "External Java Application"? And
I'm a little confused about:

> Adding the jar file containing the class to the build path fixed the
> problem.

How is a run/debug launch configuration item able to resolve your class if
you didn't have your jar in your build path in the first place? Providing
us with more details will help us determine whether this is a bug.

Thanks.

"Mark" <markjcarman@gmail.com> wrote in message
news:dc63a496088dca1a1b06b3fffb24b1ad$1@www.eclipse.org...
> 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 Go to previous message
Eclipse UserFriend
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"));
Previous Topic:plugin project that references a java project, running junit plugin class def not found problems
Next Topic:java.lang.NoClassDefFoundError: org/eclipse/emf/edit/domain/EditingDomain
Goto Forum:
  


Current Time: Fri Nov 28 21:59:08 GMT 2014

Powered by FUDForum. Page generated in 0.03046 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software