IBM Support

IBM Java for AIX How To: Resolve UnsatisfiedLinkError with a GUI based application

How To


Summary

IBM Java for AIX How To: Resolve UnsatisfiedLinkError with a GUI based application

Objective


Steps

Graphical UI based applications have dependency on some open source shared libraries like X11, that are available through AIX Tool box as RPM packages. Not having the correct libraries installed or not installed at the correct levels will result in an application failure. When this error occurs, typically one can expect to see a "java.lang.UnsatisfiedLinkError" message logged on the application's console or application's log file.

If the application is not GUI based, do not continue with this technote, instead refer to the following technote for further steps to troubleshoot the issue:
https://www-01.ibm.com/support/docview.wss?uid=isg3T1024612
Overview
Step-by-Step Instructions
Examples / Tips / Hints / Comments / Descriptions
Step 1:

Validate

Error similar to the one listed below will be written to standard output (stdout), standard error (stderr), or to an application log file, depending on the application's configuration:

java.lang.UnsatisfiedLinkError: /usr/java71/jre/lib/ppc/xawt/libmawt.so
( 0509-022 Cannot load module /usr/java71/jre/lib/ppc/xawt/libmawt.so.
0509-150 Dependent module /opt/freeware/lib/libXrender.a(shr.o) could not be loaded.

0509-152 Member shr.o is not found in archive
0509-022 Cannot load module /usr/java71/jre/lib/ppc/xawt/libmawt.so.
0509-150 Dependent module /usr/java71/jre/lib/ppc/xawt/libmawt.so could not be loaded.) at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1256) at java.lang.System.load(System.java:528) at java.lang.ClassLoader.loadLibraryWithPath(Native Method) at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1248) at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1221) at java.lang.System.loadLibrary(System.java:541) at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:80) at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:60) at java.security.AccessController.doPrivileged(AccessController.java:396) at java.awt.Toolkit.loadLibraries(Toolkit.java:1668) at java.awt.Toolkit.(Toolkit.java:1697) at java.awt.Component.(Component.java:607)


java.lang.UnsatisfiedLinkError: Could not load SWT library.
Reasons: /appl/IBM/InstallationManager/eclipse/configuration/org.eclipse. osgi/bundles/41/1/.cp/libswt-pi-gtk-4239.a

(The file access permissions do not allow the specified action.)
swt-pi-gtk (Not found in java.library.path)
/home/appuser/.swt/lib/aix/ppc/libswt-pi-gtk-4239.a
(The file access permissions do not allow the specified action.)
/home/appuser/.swt/lib/aix/ppc/libswt-pi-gtk.a
( 0509- 022 Cannot load module /home/appuser/.swt/lib/aix/ppc/liblibswt-pi-gtk. a.so.
0509-026 System error: A file or directory in the path name does not exist.) at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331) at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240) at org.eclipse.swt.internal.gtk.OS.(OS.java:23) at java.lang.J9VMInternals.initializeImpl(Native Method)
...


java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
/home/webadmin/.ibm/WebSphere/AppServer/configurations/WCT90/org.eclipse.osgi/82/0/.cp/libswt-pi-gtk-4528.a (Could not load module /usr/lib/libglib-2.0.a(libglib-2.0.so.0).

Dependent module /usr/lib/libiconv.a(libiconv.so.2) could not be loaded.
Member libiconv.so.2 is not found in archive
Could not load module /home/webadmin/.ibm/WebSphere/AppServer/configurations/WCT90/org.eclipse.osgi/82/0/.cp/libswt-pi-gtk-4528.a.
Dependent module /usr/lib/libglib-2.0.a(libglib-2.0.so.0) could not be loaded.)
swt-pi-gtk (Not found in java.library.path)
/home/webadmin/.swt/lib/aix/ppc64/libswt-pi-gtk-4528.a (Could not load module /usr/lib/libglib-2.0.a(libglib-2.0.so.0).
Dependent module /usr/lib/libiconv.a(libiconv.so.2) could not be loaded.
Member libiconv.so.2 is not found in archive
Could not load module /home/webadmin/.swt/lib/aix/ppc64/libswt-pi-gtk-4528.a.
Dependent module /usr/lib/libglib-2.0.a(libglib-2.0.so.0) could not be loaded.)
/home/webadmin/.swt/lib/aix/ppc64/libswt-pi-gtk.a (Could not load module /home/webadmin/.swt/lib/aix/ppc64/liblibswt-pi-gtk.a.so.
System error: No such file or directory)


java.lang.UnsatisfiedLinkError: fontmanager
( 0509- 022 Cannot load module /usr/WebSphere/AppServer/java/8. 0/jre/lib/ppc64/libawt_xawt.so.
0509-150 Dependent module /opt/freeware/lib/libXrender.a (shr_64.o) could not be loaded.

0509-152 Member shr_64.o is not found in archive
0509-022 Cannot load module /usr/WebSphere/AppServer/java/8. 0/jre/lib/ppc64/libfontmanager.so.
0509-150 Dependent module /usr/WebSphere/AppServer/java/8. 0/jre/lib/ppc64/libawt_xawt.so could not be loaded.) at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java: 1426) at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader. java:1391) at java.lang.System.loadLibrary(System.java:567) ...

For example, IBM Watson Explorer Analytical Components (WEX AC) uses an installer running on the Flexera InstallAnywhere Platform,which has configuration dependencies and not having the correct open source shared libraries at the correct level results in the following error message in the console or the application log:

Please report the following to IA Engineering:
XMLScriptReader: ERROR during instantiation of object. This object was lost! refID: null - class: com.zerog.ia.installer.Installer
java.lang.UnsatisfiedLinkError: fontmanager ( 0509-022 Cannot load module /tmp/install.dir.11665778/AIX/resource/jre/jre/lib/ppc/libawt_xawt.so.
0509-150 Dependent module /usr/lib/libXrender.a(shr.o) could not be loaded.
0509-152 Member shr.o is not found in archive

Step 2:

Check List

A. Verify if the module or shared library exists on the system

To search for the library execute the following command:

# lslpp -w LIBRARY NAME FROM ERROR MESSAGE


B. Check for 'symlinks'

If the module is a 'symlink', check where it is pointing to:

# ls -l LIBRARY NAME FROM ERROR MESSAGE

and make sure that the rpm packages related to those shared libraries are installed and are at the latest level:

# lslpp -l FILESET CONTAINING THE MISSING LIBRARY


C. Install rpm packages at the latest level

If the libraries are missing or at a older release level, most recent packages of these libraries are available from AIX Tool Box at:

https://www.ibm.com/developerworks/aix/library/aix-toolbox/alpha.html

RPM dependency issues may arise after the single RPM package is installed. To avoid those, simply download and install a bundle which contains all required rpms from AIX toolbox. This bundle is called gtk2_bundle_for_AIX_ALL and contains all the rpms and a nice install script, install.sh that can be used to install the bundle.

Once the library has been updated, check the version:

# rpm -ql LIBRARY NAME FROM ERROR MESSAGE

D. Set environment variable 'LIBPATH'

Set the LIBPATH to include the path to the newly installed libraries:

# export LIBPATH=PATH TO THE LIBRARY:$LIBPATH

Once all the above are done, test to see if the application runs successfully or not. If it does not, please proceed with the next steps.

A. When the error shows the missing dependent module as '/usr/lib/libXrender.a', run the following command:

$ lslpp -w /usr/lib/libXrender.a

Output should be similar to:

File Fileset Type
----------------------------------------------------------------------------
/usr/lib/libXrender.a X11.base.lib Symlink

B. Use the fileset name from the above output in the following command to check the release level of the :

$ lslpp -l X11.base.lib

Output should be similar to:

Fileset Level State Description
----------------------------------------------------------------------------
Path: /usr/lib/objrepos
X11.base.lib 7.1.4.31 COMMITTED AIXwindows Runtime Libraries

Check the symlink of the shared library, if any, by executing the command:

$ ls -l /usr/lib/libXrender.a
lrwxrwxrwx 1 root system 30 Jun 02 2018 /usr/lib/libXrender.a -> /opt/freeware/lib/


C.

$ rpm -ql libXrender
/opt/freeware/doc/libXrender-0.9.10/AUTHORS
/opt/freeware/doc/libXrender-0.9.10/COPYING
/opt/freeware/doc/libXrender-0.9.10/ChangeLog
/opt/freeware/lib/libXrender.a

D. For example, in the above output, the library is located at '/opt/freeware/lib', then

$ export LIBPATH=/opt/freeware/lib:$LIBPATH

Step 3:

Verify

To verify if the issue is with IBM Java or with the specific shared library dependencies the GUI based application install has, do the following steps:

A. Create a Sample Java program

Create a Sample Java program, 'SwingExample.java', with the following code on the AIX system:

# vi SwingExample.java

Copy lines in between "====" lines into the SwingExample.java file:

//===============
import javax.swing.*;
public class SwingExample {
public static void main(String[] args) {
JFrame f=new JFrame();//creating instance of JFrame

JButton b=new JButton("click");//creating instance of JButton
b.setBounds(130,100,100, 40);//x axis, y axis, width, height

f.add(b);//adding button in JFrame

f.setSize(400,500);//400 width and 500 height
f.setLayout(null);//using no layout managers
f.setVisible(true);//making the frame visible
}
}
//===============

B. Set the DISPLAY environment variable

to local host if the AIX machine has a GUI environment:

# export DISPLAY=:0.0

If AIX machine has no GUI environment and you are using X11 forwarding and connecting remotely through SSH to the AIX machine, set the DISPLAY on the AIX machine to the remote system from which you are connecting to the AIX system:

# export DISPLAY= IP ADDRESS OF THE REMOTE SYSTEM:0.0

Make sure an Xserver is running on this remote system to which the DISPLAY is set.

C. Compile and run the Java program with default Java and Java bundled with the application

Compile and run the program with the default Java install in /usr on the system:
# /usr/javaX_64/bin/javac SwingExample.java
# /usr/javaX_64/bin/java SwingExample

D. Repeat compiling and running the Java program with the specific Java install that the application is packaged with:

# DIRECTORY OF JAVA INSTALL BUNDLED WITH APP/bin/javac SwingExample.java
#
DIRECTORY OF JAVA INSTALL BUNDLED WITH APP
/bin/java SwingExample

E. Note which Java install reproduced the 'UnsatisfiedLinkError'.

B. If the DISPLAY variable is not set and you run the program, you will see the following error:

# /usr/java8_64/bin/java SwingExample
Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:217)
at java.awt.Window.(Window.java:547)
at java.awt.Frame.(Frame.java:431)
at java.awt.Frame.(Frame.java:396)
at javax.swing.JFrame.(JFrame.java:200)
at SwingExample.main(SwingExample.java:4)

Set the DISPLAY variable appropriately to local host or a remote system.



If DISPLAY variable is set to local host where there is no GUI environment, running the program will result in the following error:

_X11TransTRANS(ibmSHMConnect) () can't connect: errno = 68
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:79)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:140)
at java.security.AccessController.doPrivileged(AccessController.java:647)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:88)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:333)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:114)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:93)
at java.awt.Window.initGC(Window.java:486)
at java.awt.Window.init(Window.java:506)
at java.awt.Window.(Window.java:548)
at java.awt.Frame.(Frame.java:431)
at java.awt.Frame.(Frame.java:396)
at javax.swing.JFrame.(JFrame.java:200)
at SwingExample.main(SwingExample.java:4)

In case of the above error, set the DISPLAY variable to a remote system that has a Xserver running.


If DISPLAY is set to a remote system that is connecting to AIX and Xserver is running on this remote system, but AIX system is not added to the list of clients that are allowed to make connections to the Xserver, running the program on AIX will result in error similar to:

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using '9.24.7.123:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:79)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:140)
at java.security.AccessController.doPrivileged(AccessController.java:647)
at sun.awt.X11GraphicsEnvironment.(X11GraphicsEnvironment.java:88)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:333)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:114)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:93)
at java.awt.Window.initGC(Window.java:486)
at java.awt.Window.init(Window.java:506)
at java.awt.Window.(Window.java:548)
at java.awt.Frame.(Frame.java:431)
at java.awt.Frame.(Frame.java:396)
at javax.swing.JFrame.(JFrame.java:20
at SwingExample.main(SwingExample.java:4)

Run the command to allow client connections on the remote system, for example:
# xhost +

C. If the program ran successfully, you will see a GUI Window(a JFrame) with a single button in the middle with label 'click'. If not, you will see the 'UnsatisfiedLinkError' recreated.

Step 4:

Open Service request

In step 3 above, if the 'UnsatisfiedLinkError' is seen when running the Sample program using Java install bundled with application, open service request with the application support team.

If the 'UnsatisfiedLinkError' is seen when running the Sample program with default Java install in /usr, then open a service request with the AIX Java Support team.

If opening a service request with AIX Java team, please collect data per the following technote and provide it once the service request is opened:

https://www-01.ibm.com/support/docview.wss?uid=isg3T1024612

Step 5:

ACTION
Step 6:

ACTION
Step 7:

ACTION
Step 8:

ACTION
Step 9:

ACTION
Step 10:

ACTION
Step 11:

ACTION
Step 12:

ACTION
Step 13:

ACTION
Step 14:

ACTION
Step 15:

ACTION
Step 16:

ACTION
Step 17:

ACTION
Step 18:

ACTION
Step 19:

ACTION
Step 20:

ACTION
Step 21:

ACTION
Document Type: Instruction
Content Type: Troubleshooting
Hardware: all Power
Operating System: all AIX Versions
IBM Java: Java 7.0 | Java 7.1 | Java 8.0
Author(s): Vidya Makineedi
Reviewer(s): Roger Leuckie

SUPPORT:

If you have a valid and active IBM Support Subscription, when reporting a Java issue, please follow the step-by-step instructions below to contact IBM to open a case for software under warranty or with an active and valid support contract.  The technical support specialist assigned to your case will confirm that you have completed these steps.

a.  Document and/or take screen shots of all symptoms, errors, and/or messages that might have occurred

b.  Capture any logs or data relevant to the situation.

c.  Contact IBM to open a case:

   -For electronic support, please visit the IBM Support Community:
     https://www.ibm.com/mysupport
   -If you require telephone support, please visit the web page:
      https://www.ibm.com/planetwide/

d.  Provide a good description of your issue and reference this technote

e.  Upload all of the details and data to your case

   -You can attach files to your case in the IBM Support Community
   -Or Upload data to IBM testcase server analysis:

    http://www.ibm.com/support/docview.wss?uid=ibm10733581

f.  Click here to submit feedback for this document.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG10","label":"AIX"},"Component":"","Platform":[{"code":"PF002","label":"AIX"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

More support for:
AIX

Software version:
All Versions

Operating system(s):
AIX

Document number:
884328

Modified date:
14 May 2019

UID

ibm10884328

Manage My Notification Subscriptions