03 Jan 2011 08:51 AM |
|
Happy New Year.
I have C++ code wrapped with a java api. I am using the java bridge to access the API and that seems to work fine. However, the java cannot seem to see the the underlying C++ libraries (my supposition here) . I get the following error:
IDL> oJBridgeSession = obj_new('IDLJavaObject$IDLJAVABRIDGESESSION')
IDL> oJe = oJBridgeSession->GetException()
IDL> help, oJe
OJE OBJREF =
A java unsatisfied link error.
I have IDL_PATH set correctly to where the underlying .so library sits. Is there a way to ensure these libraries get loaded? Or am I asking too much of IDL? (BTW the I have been referencing the "IDL Connectivity Bridges" and "External Development Guide" to no avail.
|
|
|
|
Deleted User New Member
Posts:25  
25 Jan 2011 02:50 PM |
|
Hi Brandon,
Thanks for your reply. I was running this on Suse Linux.
If I just run the command lines above in a fresh window, I too get the exception object equal to NULLOBJECT.
I guess I was not clear enough in my orginal message. I have an IDL program that calls a java wrapper - the java wrapper wraps C++ code. When I run this IDL program, java throws an exception. Once that happens, I executed the above code to show what type of exception I was getting.
The java wrappers seems not to be able to link to the underlying c++ code. I have my LD_LIBRARY_PATH set correctly and java.library.path (I think also I have my java.class.path set) - these have all been verified. But the java still does not seem to the find the library (java.langUnsatisfiedLinkError). I thought I was missing something - something needs to be set, but I cannot figure what, if anything, that is.
Any ideas are welcome.
Thanks
|
|
|
|
Deleted User New Member
Posts:25  
02 Feb 2011 01:06 PM |
|
My problem seems to occur when calling the underlying JNI method (see below).
% java.lang.UnsatisfiedLinkError: jstats.statsJNI.printStats()V
% at jstats.statsJNI.printStats(Native Method)
% at jstats.stats.printStats(stats.java:29)
% at com.rsi.idldt.core.ips.IPS_Access.IPS_Start(Native Method)
% at com.rsi.idldt.core.ips.IPS_Manager$2.run(IPS_Manager.java:383)
% at java.lang.Thread.run(Thread.java:619)
The IDLJAVABRIDGESESSION uses JNI as well - from the bridge document "Method calls are the same as any other IDL object, but they are vectored off to an IDL Java system, which will call the appropriate Java method using JNI."
In fact, the methods inheirited from java.lang.object class (e.g. getClass() ) work fine in the java object that I create. Is there a trick to getting the JNI call to work in IDL?
|
|
|
|
Deleted User New Member
Posts:25  
03 Feb 2011 07:26 AM |
|
Well, I finally figured out my problem and I will share it here so that others may benefit. Note this is my first time working with java, so understand I am new to it. Seems I was doing the right thing but in the wrong place.
I was trying to load the library in my IDL java object, but I needed to do this in my JNI class instead.
I was doing in IDL:
jSys = obj_new('idljavaobject$static$system', 'java.lang.System')
jSys->loadLibrary('my_lib')
which did not do anything (but did not seem harmful either).
Turns out that I needed more java code in my JNI class:
static {
try {
System.loadLibrary("my_lib");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
}
}
This solved my problem.
|
|
|
|