Jenkins fails to start with JNA error

Issue

Attempting to start CloudBees Jenkins Enterprise or CloudBees Jenkins Operations Center results in a stacktrace similar to the one below:

Starting CloudBees Jenkins Enterprise Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at Main._main(Main.java:140)
at Main.main(Main.java:98)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna--1712433994/jna7387046629130767794.tmp: /tmp/jna--1712433994/jna7387046629130767794.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:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.<clinit>(Native.java:131)
at com.sun.akuma.CLibrary.<clinit>(CLibrary.java:89)
at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
at com.sun.akuma.Daemon.all(Daemon.java:88)
... 6 more

Environment

  • CloudBees Jenkins Enterprise
  • CloudBees Jenkins Operations Center

Resolution

The issue is being caused by the noexec settings for the /tmp directory. These settings are preventing the Jenkins process to launch the JNA library from the /tmp directory.

To resolve the issue, please do either of the following.

Option 1: Change the temporary directory of Jenkins

To change the temporary directory that Jenkins uses, you need to:

  • append -Djava.io.tmpdir=$JENKINS_HOME/tmp into JENKINS_JAVA_OPTIONS variable in either /etc/sysconfig/jenkins or /etc/default/jenkins file depending on your OS
  • create /var/lib/jenkins/tmp using the Unix user that runs the Jenkins process

Option 2: Fix the mount option of /tmp

As root, edit /etc/fstab configuration file and remove noexec from the mount option of /tmp directory. Then run:

mount -o remount /tmp

to apply the modification.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.