Skip to content

java.lang.UnsatisfiedLinkError: Could not load SWT library #1669

@AlBundy33

Description

@AlBundy33

Describe the bug
Statically loading a class that extends Scrollable ends in this exception on headless servers (e.g. ci/cd pipelines)

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: 
	no swt-pi4-gtk-4934r6 in java.library.path: [/opt/java/openjdk/lib/server, /opt/java/openjdk/lib, /opt/java/openjdk/../lib, /usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
	no swt-pi4-gtk in java.library.path: [/opt/java/openjdk/lib/server, /opt/java/openjdk/lib, /opt/java/openjdk/../lib, /usr/java/packages/lib, /usr/lib64, /lib64, /lib, /usr/lib]
	Can't load library: /root/.swt/lib/linux/x86_64/libswt-pi4-gtk-4934r6.so
	Can't load library: /root/.swt/lib/linux/x86_64/libswt-pi4-gtk.so
	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:342)
	at org.eclipse.swt.internal.Library.loadLibrary(Library.java:256)
	at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:90)
	at org.eclipse.swt.widgets.Scrollable.<clinit>(Scrollable.java:44)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:315)
....

It seems that this call

static final boolean RESIZE_ON_GETCLIENTAREA = OS.isWayland() || Boolean.getBoolean("org.eclipse.swt.resizeOnGetClientArea");

causes the load of a native library

we are analyzing the classes during our build and therefore load classes with Class.forName

I think we have this error wirh RCP 4.16 (have to check this in detail if necessary)

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions