5

First off, here is what is working, and then I'll describe what is not: Using SWIG, we have taken some third party code, and created the Java and C wrapper source. A jar file of the Java classes, and a shared library of the C wrapper code was created. We have a Java codebase that loads the shared library, and is able to invoke the native code as needed. This is running on Sun HostSpot JVM 1.5.0.14. No worries here.

Now, this is not working: Using the same JVM, jar file with of the Java wrapper code, and same shared library described above, I am trying to use Jython to do some scripting. The CLASSPATH and LD_LIBRARY_PATH environment vars are set correctly. From Jython, I am able to run java.lang.System.loadLibrary(...), and load the shared library without error. However, when the first native method from this library that is invoked for a Java object in my Jython script, I get an UnsatisfiedLinkError from the JVM.

I ran nm on the shared library, and I see that the method in question is present in the library (with the name mangling for native methods as described in the JNI spec). So, the question is, what could be stopping the JVM from resolving the method name?

I've been through the JNI spec, and I see that a library can be unloaded by the GC. Could that be happening before I invoke the method? What else can cause this to fail?

jbrogdon
  • 671
  • 1
  • 7
  • 15
  • 1
    I did. Unfortunately, I didn't do the good neighbor thing, and publicize the solution :). Now, I'm having to do it by memory. I believe I had to get very explicit with the imports in my script. I could not simply `import .`. I had to use: `from import `. – jbrogdon Nov 12 '12 at 21:48

1 Answers1

0

I have had this issue before. In my case the DLL/.so library being loaded had further dependencies that were not found and the error message only reported the library I was trying to load. I used the tools below to figure out the missing dependencies.

If you are on windows, use the Process Monitor http://technet.microsoft.com/en-us/sysinternals/bb896645 to see the exact DLLs that are being searched for by your application. You will need to start Process Monitor then run your app and filter through the logs to see which dlls your application is looking for.

If you are on linux, use strace ( http://en.wikipedia.org/wiki/Strace ) and see which shared library is missing.

Nicky
  • 61
  • 5