Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
After building against OpenJDK 6b24-1.11.4-3 (Debian amd64) using
mvn -Pnative,dist clean package -Dmaven.javadoc.skip=true -DskipTests -Dtar
the resulting binaries libhadoop.so and libhdfs.so are linked to the wrong libjvm.so:
% LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server ldd hadoop-dist/target/hadoop-3.0.0-SNAPSHOT/lib/native/libhadoop.so.1.0.0
linux-vdso.so.1 => (0x00007fff8c7ff000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f31df30e000)
libjvm.so.0 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f31def86000)
/lib64/ld-linux-x86-64.so.2 (0x00007f31df73d000)
Inspecting the build output it appears that JNIFlags.cmake decided, mysteriously, to link against /usr/lib/jvm/default-java/jre/lib/amd64/jamvm/libjvm.so, based on:
[exec] JAVA_HOME=, JAVA_JVM_LIBRARY=/usr/lib/jvm/default-java/jre/lib/amd64/jamvm/libjvm.so [exec] JAVA_INCLUDE_PATH=/usr/lib/jvm/default-java/include, JAVA_INCLUDE_PATH2=/usr/lib/jvm/default-java/include/linux [exec] Located all JNI components successfully.
The "jamvm" is not mentioned anywhere in my environment or any symlinks in /usr, so apparently cmake iterated over the directories in /usr/lib/jvm/default-java/jre/lib/amd64 to find it. The following libjvm.so files are present on this machine:
-rw-r--r-- 1 root root 1050190 Sep 2 13:38 /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/cacao/libjvm.so -rw-r--r-- 1 root root 1554628 Sep 2 11:21 /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so -rw-r--r-- 1 root root 12193850 Sep 2 13:38 /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server/libjvm.so
Note the difference between libjvm.so and libjvm.so.0; the latter seems to come from the DT_SONAME in jamvm/libjvm.so, but that library seems to just be broken since there's no libjvm.so.0 symlink anywhere on the filesystem. I suspect that is a bug in OpenJDK but we should just avoid the issue by finding the right value for JAVA_JVM_LIBRARY.