Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ClassLoader and JNI issues

Reply
Thread Tools

ClassLoader and JNI issues

 
 
Steve Menard
Guest
Posts: n/a
 
      06-24-2004
I am having problems calling JDBC code from C/C++ via JNI.

I am embedding the JVM, and need access to any JDCB driver.

My problem is the following :

I can get the driver registered no problem, but when it comes time to
try and connect, the DriverManager "skips" over it because the driver's
ClassLoader is not the same as the caller's ClassLoader.

Now, I am calling this from C/C++ code, so there is no caller class, and
so no caller classloader.

I can make it work by bypassing th DriverManager completely, and asking
the driver to connect itself. That's fine as a stopgap solution, but I
would really like to fix this. The same problem occurs when I call
Class.forName(String), as this method looks at the caller's class and
classloader.

Is there a way to set or simulate a current class and/or classloader?

thanks in advance,

Steve
 
Reply With Quote
 
 
 
 
Chris Uppal
Guest
Posts: n/a
 
      06-25-2004
Steve Menard wrote:

> I can get the driver registered no problem, but when it comes time to
> try and connect, the DriverManager "skips" over it because the driver's
> ClassLoader is not the same as the caller's ClassLoader.
>
> Now, I am calling this from C/C++ code, so there is no caller class, and
> so no caller classloader.


The only thing /I/ can think of is to work around the problem with a bit of
"helper" Java code. That code just forwards to the actual methods you want to
invoke. So you call your helper code from JNI, rather than calling the "real"
methods directly.

I had to use a similar technique to workaround a buggy implementation of the
reflective methods in BEA JRockit implementation (presumably the problem was
related to the same issue).

-- chris


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ClassCastException - ClassLoader issues Berlin Brown Java 1 09-25-2006 09:45 PM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:03 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
Porting JNI Windows under JNI LINUX + Wine ? Pasturel Jean-Louis Java 5 03-03-2004 07:50 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM



Advertisments