Solutions
ForgeRock Identity Platform
Does not apply to Identity Cloud

Could not load library error when trying to run Amster after installing it for AM 7.x

Last updated Jul 22, 2021

The purpose of this article is to provide assistance if you encounter an "Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load library" error when trying to run Amster for the first time after installing it.


Symptoms

An error similar to the following is shown when you run the amster command:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi64-7.1.0 - 2021-May-10 11:06:52 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib], no jansi-7.1.0 - 2021-May-10 11:06:52 in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib], no jansi in java.library.path: [/usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib], /tmp/libjansi-64-7-6151295137849897833.1: /tmp/libjansi-64-7-6151295137849897833.1: failed to map segment from shared object: Operation not permitted]   at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)    at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)    at org.fusesource.jansi.internal.CLibrary.<clinit>(CLibrary.java:42)    at org.fusesource.jansi.AnsiConsole.wrapOutputStream(AnsiConsole.java:48)    at org.fusesource.jansi.AnsiConsole.<clinit>(AnsiConsole.java:38)    at java.base/java.lang.Class.forName0(Native Method)    at java.base/java.lang.Class.forName(Class.java:398)    at org.codehaus.groovy.runtime.callsite.CallSiteArray.lambda$createCallStaticSite$2(CallSiteArray.java:65)    at java.base/java.security.AccessController.doPrivileged(Native Method)    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:63) ...

Recent Changes

Installed Amster for AM 7.x.

Causes

Amster 7 and later uses the Jansi library to format the command line output, and this library is packaged in the amster-7.x.x.jar file. 

During startup, Amster extracts the shared Jansi library to the /tmp directory and then loads it from there. If the user who runs Amster does not have read-write access to the /tmp directory, startup fails with this error message. This permissions issue often occurs because of additional security hardening. For example, you are using SELinux, the /tmp directory has been mounted using the NOEXEC flag or, in a containerized environment, the /tmp directory has been mounted using a configmap with stricter permissions.

Solution

This issue can be resolved using one of the following options depending on whether you can change the permissions:

  • Give the user account that runs Amster read-write access to the /tmp directory.
  • Create a new /temp directory for Amster to use as follows:
    1. Create a directory called /temp under the main Amster directory, for example:$ mkdir /path/to/amster/temp
    2. Add the following JVM property to the amster script (located in the /path/to/amster directory):-Djava.io.tmpdir=/path/to/amster/tempThis property should be added to the $JAVA_HOME line so it looks similar to this:$JAVA_HOME/bin/java $debug -Djava.awt.headless=true -Djava.io.tmpdir=/path/to/amster/temp -jar ${DIR}/amster-*.jar $*

See Also

Amster User Guide

Related Training

N/A

Related Issue Tracker IDs

N/A


Copyright and Trademarks Copyright © 2021 ForgeRock, all rights reserved.