We provide a Java API wrapper around one of our 32 bit applications (written in C). This wrapper uses JNI to load the libray.
We have encountered a problem where we cannot get the application to work on AIX 6.1 under IBM J9 1.6.0 (32 bit), but it works fine under 1.5.0 (32 bit).
We use a script that does this:
/usr/java6/jre/bin/java -Xms512M -Xmx1G <...removed remaining arguments...>
Here is the error we get:
Java: Could not load the nativejs library: java.lang.UnsatisfiedLinkError: nativejs (A file or directory in the path name does not exist.)
I have done much analysis and testing to make sure that Java can indeed locate our native library (libnativejs.so). Here's the Java version information for the JVM I'm calling (note that it is 32 bit).
$ /usr/java6/jre/bin/java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr9fp2-20110627_03(SR9 FP2))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr9-20110624_85526 (JIT enabled, AOT enabled)
J9VM - 20110624_085526
JIT - r9_20101028_17488ifx17
GC - 20101027_AA)
JCL - 20110530_01
When we use this command to run use the 1.5.0 JVM, the program runs successfully:
/usr/java5/jre/bin/java -Xms512M -Xmx1G <...removed remaining arguments...>
Here's the version info for that JVM:
$ /usr/java5/jre/bin/java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap32devifx-20110627 (SR12 FP5 ))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc-32 j9vmap3223ifx-20110624 (JIT enabled)
J9VM - 20110623_85457_bHdSMr
JIT - 20100623_16197ifx10_r8
GC - FP22011_06)
JCL - 20110627
I also used truss to trace the loading of my library (libnativejs.so). I can see various statx statements showing unsuccessful searches for the library, for example:
statx("/usr/java6/jre/lib/ppc/libnativejs.a", 0x3012E900, 128, 010) Err#2 ENOENT
statx("/usr/java6/jre/lib/ppc//usr/java6/jre/lib/ppc/j9vm/libnativejs.so", 0x3012E900, 128, 010) Err#2 ENOENT
...until it does locate the library:
statx("/actu01/home/pdcomp/xgprod/bin/libnativejs.so", 0x3012E900, 128, 010) = 0
loadquery(2, 0x330BDB48, 0x00000400) Err#12 ENOMEM
loadquery(2, 0x330BDB48, 0x00000800) Err#12 ENOMEM
loadquery(2, 0x33188B18, 0x00001000) = 0
I believe the "Err#12 ENOMEM" is the result of some memory allocation issue, but I cannot seem to find any examples of this behavior online.
Again, this works fine in Java 1.5.0, so I wonder if this is a JVM related defect.
Does anyone have any ideas?
Pinned topic UnsatisfiedLinkError on AIX 6.1 with Java 1.6, works fine with Java 1.5
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-08-28T08:16:58Z at 2012-08-28T08:16:58Z by tvheros2
Dave416 270005M3TQ2 Posts
Re: UnsatisfiedLinkError on AIX 6.1 with Java 1.6, works fine with Java 1.52012-08-24T21:00:03ZThis is the accepted answer. This is the accepted answer.We're getting the same result on Java7 SR1.
Any suggestions on how to troubleshoot this further would be greatly appreciated.
tvheros2 060001R8CX1 Post
Re: UnsatisfiedLinkError on AIX 6.1 with Java 1.6, works fine with Java 1.52012-08-28T08:16:58ZThis is the accepted answer. This is the accepted answer.
- Dave416 270005M3TQ
you have to compile your library with the jdk you want to use.
The include file jni.h contains the env struct which is used by JNI. This struct can change from a 1.5, 1.6 or 1.7 java version causing a bad memory access.