Jenkins fails to start with JNA error

Article ID:215281717
1 minute readKnowledge base

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

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:

  1. Create $JENKINS_HOME/tmp folder (e.g. /var/lib/jenkins/tmp for Jenkins LTS Red Hat distributions) using the Unix user that runs the Jenkins process (e.g. same $JENKINS_USER under /etc/sysconfig/jenkins for Jenkins LTS Red Hat distributions)

  2. Append -Djava.io.tmpdir=$JENKINS_HOME/tmp into JENKINS_JAVA_OPTIONS variable (e.g. in the /etc/sysconfig/jenkins file for for Jenkins LTS Red Hat distributions

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.

This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.