JRuby JNI bug, or I'm doing something wrong?

I’m running into issues with a JNI library, and I’ve been banging my
head against a wall trying to figure out what I’m doing wrong. The
logical conclusion seems to be that there is perhaps a bug in JRuby, but
I’d really appreciate any thoughts that the community has.

Here is some trivial Java code that works properly with the library and
the commands that I use to compile and execute the code.

DirectoryOpen.java

import misapi.MISDirectory;
import misapi.JvmUtil;

public class DirectoryOpen
{
public static void main( String[] args )
{
System.load("/usr/local/lib64/libMisApiJni.so");
JvmUtil jvmUtil = new JvmUtil();
jvmUtil.vmInit();

MISDirectory mis_d = new MISDirectory( );

System.out.println( "SUCCESS!" );

}
}

[08:45 PM] user@boonen :: /usr/local/data/pamg $ javac -cp
/usr/local/lib64/misapi.jar DirectoryOpen.java
[08:47 PM] user@boonen :: /usr/local/data/pamg $ java
-Djava.library.path=/usr/local/lib64 -cp /usr/local/lib64/misapi.jar:.
DirectoryOpen
SUCCESS!

Here is an equivalent JRuby program and the result of running the
commands at the bottom

require ‘java’

java_import ‘java.lang.System’
java_import ‘misapi.MISDirectory’
java_import ‘misapi.JvmUtil’

System.load( ‘/usr/local/lib64/libMisApiJni.so’ )

jvm_util = JvmUtil.new( )
jvm_util.vmInit( )

mis_d = MISDirectory.new( )

puts “SUCCESS”

[08:49 PM] user@boonen :: /usr/local/data/pamg $ jruby-1.7
-J-Djava.library.path=/usr/local/lib64 -J-cp /usr/local/lib64/misapi.jar
directory_open.rb

null:-2:in initJVM': java.lang.UnsatisfiedLinkError: misapi.JvmUtil.initJVM()V from null:-1:invmInit’
from NativeMethodAccessorImpl.java:-2:in invoke0' from NativeMethodAccessorImpl.java:57:ininvoke’
from DelegatingMethodAccessorImpl.java:43:in invoke' from Method.java:616:ininvoke’
from JavaMethod.java:440:in invokeDirectWithExceptionHandling' from JavaMethod.java:304:ininvokeDirect’
from InstanceMethodInvoker.java:52:in call' from CachingCallSite.java:306:incacheAndCall’
from CachingCallSite.java:136:in call' from directory_open.rb:13:infile
from directory_open.rb:-1:in load' from Ruby.java:815:inrunScript’
from Ruby.java:808:in runScript' from Ruby.java:679:inrunNormally’
from Ruby.java:528:in runFromMain' from Main.java:390:indoRunFromMain’
from Main.java:279:in internalRun' from Main.java:221:inrun’
from Main.java:201:in `main’

What may be a hint to the problem, if I make the following change, I
receive the output below. If I define java.library.path correctly,
which I seem to be setting it properly on the CLI, I should be able to
use loadLibrary with a relative pathname, and not load( ), which
requires the absolute pathname.

  • System.loadLibrary( ‘MisApiJni’ )
  • System.load( ‘/usr/local/lib64/libMisApiJni.so’ )

[08:50 PM] user@boonen :: /usr/local/data/pamg $ jruby-1.7
-J-Djava.library.path=/usr/local/lib64 -J-cp /usr/local/lib64/misapi.jar
directory_open.rb

ClassLoader.java:1681:in loadLibrary': java.lang.UnsatisfiedLinkError: no MisApiJni in java.library.path from Runtime.java:840:inloadLibrary0’
from System.java:1047:in loadLibrary' from NativeMethodAccessorImpl.java:-2:ininvoke0’
from NativeMethodAccessorImpl.java:57:in invoke' from DelegatingMethodAccessorImpl.java:43:ininvoke’
from Method.java:616:in invoke' from JavaMethod.java:455:ininvokeDirectWithExceptionHandling’
from JavaMethod.java:367:in invokeStaticDirect' from StaticMethodInvoker.java:60:incall’
from CachingCallSite.java:326:in cacheAndCall' from CachingCallSite.java:170:incall’
from directory_open.rb:9:in __file__' from directory_open.rb:-1:inload’
from Ruby.java:815:in runScript' from Ruby.java:808:inrunScript’
from Ruby.java:679:in runNormally' from Ruby.java:528:inrunFromMain’
from Main.java:390:in doRunFromMain' from Main.java:279:ininternalRun’
from Main.java:221:in run' from Main.java:201:inmain’

Any thoughts would be greatly appreciated!

Cheers,
Jon