JNA code does not work if tmpdir is mounted noexec
Description
At a customer site, Tarus saw an error at startup related to JNA initialization:
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna1682786434384331136.tmp: /tmp/jna1682786434384331136.tmp: failed to map segment from shared object: Operation not permitted at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699) at java.lang.Runtime.load0(Runtime.java:770) at java.lang.System.load(System.java:1003) at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:761) at com.sun.jna.Native.loadNativeLibrary(Native.java:685) at com.sun.jna.Native.<clinit>(Native.java:109) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.productivity.java.syslog4j.util.SyslogUtility.isClassExists(Unknown Source) at org.productivity.java.syslog4j.Syslog.initialize(Unknown Source) at org.productivity.java.syslog4j.Syslog.<clinit>(Unknown Source) at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounder.createNorthboundInstance(SyslogNorthbounder.java:329) at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounder.afterPropertiesSet(SyslogNorthbounder.java:91) at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounderManager.afterPropertiesSet(SyslogNorthbounderManager.java:68) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419) ... 90 more
It appears the problem is that the JVM is not allowed to mmap/load a file that's been unpacked into /tmp because /tmp is mounted noexec.
Acceptance / Success Criteria
None
Lucidchart Diagrams
Activity
Show:
Benjamin Reed August 28, 2013 at 3:58 PM
I set up a VM and I was able to confirm that if /tmp is mounted noexec, the JNA code fails at startup.
I've committed a fix to 1.12 that sets the tmpdir to $OPENNMS_HOME/data/tmp since that's created by karaf anyways.
At a customer site, Tarus saw an error at startup related to JNA initialization:
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna1682786434384331136.tmp: /tmp/jna1682786434384331136.tmp: failed to map segment from shared object: Operation not permitted
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1699)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:761)
at com.sun.jna.Native.loadNativeLibrary(Native.java:685)
at com.sun.jna.Native.<clinit>(Native.java:109)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.productivity.java.syslog4j.util.SyslogUtility.isClassExists(Unknown Source)
at org.productivity.java.syslog4j.Syslog.initialize(Unknown Source)
at org.productivity.java.syslog4j.Syslog.<clinit>(Unknown Source)
at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounder.createNorthboundInstance(SyslogNorthbounder.java:329)
at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounder.afterPropertiesSet(SyslogNorthbounder.java:91)
at org.opennms.netmgt.alarmd.northbounder.syslog.SyslogNorthbounderManager.afterPropertiesSet(SyslogNorthbounderManager.java:68)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 90 more
It appears the problem is that the JVM is not allowed to mmap/load a file that's been unpacked into /tmp because /tmp is mounted noexec.