oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.39k stars 1.64k forks source link

no awt in java.library.path #2842

Closed abamoshe closed 3 years ago

abamoshe commented 4 years ago

hare is my project https://github.com/abamoshe/ConnectWise_portable/releases/tag/0.0.0 im running native-image -jar ConnectWise.jar --no-fallback -H:NativeLinkerOption=prefs.lib and on runtime i get this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
        at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary(NativeLibrarySupport.java:131)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:228)
        at java.lang.Runtime.loadLibrary0(Runtime.java:830)
        at java.lang.Runtime.loadLibrary(Runtime.java:238)
        at java.lang.System.loadLibrary(System.java:352)
        at java.awt.Toolkit$3.run(Toolkit.java:1395)
        at java.awt.Toolkit$3.run(Toolkit.java:1393)
        at java.security.AccessController.doPrivileged(AccessController.java:83)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1425)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
        at java.awt.SystemTray.addNotify(SystemTray.java:503)
        at java.awt.SystemTray.<init>(SystemTray.java:150)
        at java.awt.SystemTray.initializeSystemTrayIfNeeded(SystemTray.java:522)
        at java.awt.SystemTray.getSystemTray(SystemTray.java:185)
        at com.aba.pconnectwise.Launcher.addTrayIcon(Launcher.java:24)
        at com.aba.pconnectwise.Launcher.main(Launcher.java:19)

(the -H:NativeLinkerOption=prefs.lib is becose of https://github.com/oracle/graal/issues/2363#issuecomment-619426179 i'v also downloaded the dev version to avoid this https://github.com/oracle/graal/issues/2363#issuecomment-664512773)

munishchouhan commented 4 years ago

@abamoshe please provide the reproduce or the instructions to reproduce this error

abamoshe commented 4 years ago

@abamoshe please provide the reproduce or the instructions to reproduce this error

just download the jar from hare https://github.com/abamoshe/ConnectWise_portable/releases/tag/0.0.0 and run native-image -jar ConnectWise.jar --no-fallback (but to avoid unresolved external symbol Java_java_util_prefs_WindowsPreferences error you need to add -H:NativeLinkerOption=prefs.lib (https://github.com/oracle/graal/issues/2363#issuecomment-619426179) and then run the compiled exe

abamoshe commented 4 years ago

@mcraj017 the problem is basically with the tray icon hare is a simple snippet of code wat makes a simple demo tray icon

import javax.imageio.ImageIO;
import java.awt.*;
import java.net.URL;

public class TrayIconDemo {
    public static void main(String[] args) throws Exception {
        SystemTray tray = SystemTray.getSystemTray();
        TrayIcon trayIcon = new TrayIcon(ImageIO.read(new URL("http://icons.iconarchive.com/icons/scafer31000/bubble-circle-3/16/GameCenter-icon.png")));
        trayIcon.setImageAutoSize(true);
        MenuItem menuExit = new MenuItem("exit");
        menuExit.addActionListener(e -> {
            tray.remove(trayIcon);
            System.exit(0);
        });
        PopupMenu popupMenu = new PopupMenu();
        popupMenu.add(menuExit);
        trayIcon.setPopupMenu(popupMenu);
        tray.add(trayIcon);
    }

}

just run javac TrayIconDemo.java then native-image TrayIconDemo --no-fallback and then trayicondemo.exe and the error

C:\Users\XXX\IdeaProjects\TrayIcon\src>trayicondemo.exe
Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
        at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary(NativeLibrarySupport.java:131)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:228)
        at java.lang.Runtime.loadLibrary0(Runtime.java:830)
        at java.lang.Runtime.loadLibrary(Runtime.java:238)
        at java.lang.System.loadLibrary(System.java:352)
        at java.awt.Toolkit$3.run(Toolkit.java:1395)
        at java.awt.Toolkit$3.run(Toolkit.java:1393)
        at java.security.AccessController.doPrivileged(AccessController.java:83)
        at java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
        at java.awt.Toolkit.<clinit>(Toolkit.java:1425)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
        at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
        at java.awt.SystemTray.addNotify(SystemTray.java:503)
        at java.awt.SystemTray.<init>(SystemTray.java:150)
        at java.awt.SystemTray.initializeSystemTrayIfNeeded(SystemTray.java:522)
        at java.awt.SystemTray.getSystemTray(SystemTray.java:185)
        at TrayIconDemo.main(TrayIconDemo.java:7)
munishchouhan commented 4 years ago

@abamoshe thanks for the reproducer

mpela81 commented 4 years ago

Having the same issue here with SystemTray.getSystemTray()

emrul commented 4 years ago

I get the same error using SXSSFWorkbook in Apache POI

java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary(NativeLibrarySupport.java:131) ~[?:?]
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:228) ~[?:?]
    at java.lang.Runtime.loadLibrary0(Runtime.java:830) ~[?:?]
    at java.lang.Runtime.loadLibrary(Runtime.java:238) ~[?:?]
    at java.lang.System.loadLibrary(System.java:352) ~[?:?]
    at java.awt.Toolkit$3.run(Toolkit.java:1395) ~[?:?]
    at java.awt.Toolkit$3.run(Toolkit.java:1393) ~[?:?]
    at java.security.AccessController.doPrivileged(AccessController.java:83) ~[Curate:?]
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1392) ~[?:?]
    at java.awt.Toolkit.<clinit>(Toolkit.java:1425) ~[?:?]
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351) ~[?:?]
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271) ~[?:?]
    at java.awt.Font.<clinit>(Font.java:261) ~[?:?]
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351) ~[?:?]
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271) ~[?:?]
    at java.awt.font.TextLayout.singleFont(TextLayout.java:468) ~[?:?]
    at java.awt.font.TextLayout.<init>(TextLayout.java:530) ~[?:?]
    at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:273) ~[?:?]
    at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117) ~[?:?]
    at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82) ~[?:?]
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:684) ~[?:?]
    at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:705) ~[?:?]
IvanLuchkin commented 4 years ago

Are there any updates on this issue? I have faced a similar problem

vjovanov commented 4 years ago

This should be fixed for the LINUX_AMD64 platform in the latest 20.3 build

fniephaus commented 4 years ago

I ran into a similar issue (see below) and just in case someone else is too on macOS: According to @vjovanov, additional work for macOS is still needed to make this work.

ERROR: java.lang.UnsatisfiedLinkError: no awt in java.library.path
org.graalvm.polyglot.PolyglotException: java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibrary(NativeLibrarySupport.java:131)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:270)
    at java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.lang.Runtime.loadLibrary(Runtime.java:239)
    at java.lang.System.loadLibrary(System.java:358)
    at java.awt.image.ColorModel$1.run(ColorModel.java:209)
    at java.awt.image.ColorModel$1.run(ColorModel.java:207)
    at java.security.AccessController.doPrivileged(AccessController.java:84)
    at java.awt.image.ColorModel.loadLibraries(ColorModel.java:206)
    at java.awt.image.ColorModel.<clinit>(ColorModel.java:219)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
    at java.lang.Class.ensureInitialized(DynamicHub.java:573)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:236)
    at java.lang.Class.ensureInitialized(DynamicHub.java:573)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:236)
    at de.hpi.swa.trufflesqueak.util.MiscUtils.<clinit>(MiscUtils.java:41)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:351)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:271)
    ...
mpela81 commented 4 years ago

And what about Windows?

vjovanov commented 4 years ago

Same, as MacOS. Still the work needed now is an order of magnitude smaller than what was necessary for LINUX.

@pejovica have you tried it out on Windows?

jayanmn commented 3 years ago

graalvm-ce-java11-20.3.0 : has same exception on windows

OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing)

graalvm-ce-java11-21.0.0-dev : has same problem on windows

OpenJDK Runtime Environment GraalVM CE 21.0.0-dev (build 11.0.9+10-jvmci-20.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.0-dev (build 11.0.9+10-jvmci-20.3-b05, mixed mode, sharing)
Skhmt commented 3 years ago

Can confirm, same problem on Windows OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06) OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing)

sherl0cks commented 3 years ago

@vjovanov I'm still hitting this with 20.3.0 Linux AMD64 CE that was released this week. Is there a build or deploy time flag needed to link libawt.so?

zakkak commented 3 years ago

FWIW in Mandrel we had to backport https://github.com/oracle/graal/commit/5d2997a9ac8cafdfc6b5c316532165839ad7d1af to 20.3 to get a similar case resolved

sherl0cks commented 3 years ago

@zakkak interesting. Is there an equivalent of https://quay.io/repository/quarkus/ubi-quarkus-native-image for mandrel 20.3.0? If so, I'd like to test that out to see if I can get this working. I can test out a CR or the like as well.

zakkak commented 3 years ago

@sherl0cks sure. It's https://quay.io/repository/quarkus/ubi-quarkus-mandrel:20.3-java11 (in Beta at the moment) :)

sherl0cks commented 3 years ago

@zakkak brilliant. Will let you know how it goes. Thank you very much!

vjovanov commented 3 years ago

Unfortunately, the AWT patch didn't make it into 20.3 as it was considered dangerous for stability. To get the code that works with AWT you will have to rely on our dev builds or wait for 21.0.

lrxit commented 3 years ago

Unfortunately, the AWT patch didn't make it into 20.3 as it was considered dangerous for stability. To get the code that works with AWT you will have to rely on our dev builds or wait for 21.0.

Will AWT feature be available for Windows native image and Java 8?

vjovanov commented 3 years ago

Java 8, most likely not. For Windows, it turns out that it is a noticeable amount of work. \CC @pejovica

lrxit commented 3 years ago

pity, imho it would represent the definitive solution to the various launchers (launch4j, jar2exe, etc)

sherl0cks commented 3 years ago

@sherl0cks sure. It's https://quay.io/repository/quarkus/ubi-quarkus-mandrel:20.3-java11 (in Beta at the moment) :)

In case anyone runs into this issue looking for AWT support, it looks like Mandrel did backport the commit, but there is still work needed to fix issues like https://github.com/quarkusio/quarkus-images/issues/114 before the mandrel images are usable. Hopefully those are resolved soon and give folks a viable path to use AWT in native.

fniephaus commented 3 years ago

@sherl0cks As @vjovanov pointed out, you can try AWT support today if you use a nightly 21.0.0-dev build of GraalVM. I suggest you use that and help test and improve support for AWT. It will make it a bit easier to identify bugs and try out new commits.

mbbee commented 3 years ago

@fniephaus i tried the nightly 21.0.0-dev build and got the same error. Had anyone success with the nighty 21.0.0-dev build and a HelloWorld - Dialog in AWT or Swing? If yes, please share a detailed howto.

sherl0cks commented 3 years ago

@fniephaus Would be happy to test out the 21.0.0 dev releases, but the build system I'm working with is set up for these docker images. If you are able to work with the quarkus folks to get a nightly dev build out through their container images, or if there is a comparable image that isn't through quarkus, I'll definitely give it a go. Unfortunately, I just don't have the bandwidth right now to setup a different build process.

Wqrld commented 3 years ago

Ive just tested the latest 21.1.0-dev build and it compiles and works correctly with basic AWT code. strangely enough this did douple my binary size so that might be something to look into if thats consistent for all programs.

javasuns commented 3 years ago

Still getting the error when calling SystemTray.isSupported()

[Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Exception in Preloader start method [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Preloader start method [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:882) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.Thread.run(Thread.java:834) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Caused by: java.lang.UnsatisfiedLinkError: no awt in java.library.path [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:275) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.Runtime.loadLibrary0(Runtime.java:830) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.System.loadLibrary(System.java:1871) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit$3.run(Toolkit.java:1395) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit$3.run(Toolkit.java:1393) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:84) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit.loadLibraries(Toolkit.java:1392) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit.(Toolkit.java:1425) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.SystemTray.isSupported(SystemTray.java:221)

Wqrld commented 3 years ago

Are you running the dev build? This hasn't been pushed to prod yet.

Op zo 27 dec. 2020 10:13 schreef javasuns notifications@github.com:

Still getting the error when calling SystemTray.isSupported()

[Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Exception in Preloader start method [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Exception in thread "main" java.lang.RuntimeException: Exception in Preloader start method [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:882) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.Thread.run(Thread.java:834) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] Caused by: java.lang.UnsatisfiedLinkError: no awt in java.library.path [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.ClassLoader.loadLibrary(ClassLoader.java:275) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.Runtime.loadLibrary0(Runtime.java:830) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.lang.System.loadLibrary(System.java:1871) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit$3.run(Toolkit.java:1395) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit$3.run(Toolkit.java:1393) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:84) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit.loadLibraries(Toolkit.java:1392) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.Toolkit.(Toolkit.java:1425) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295) [Sun Dec 27 11:07:04 EET 2020][INFO] [SUB] at java.awt.SystemTray.isSupported(SystemTray.java:221)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/oracle/graal/issues/2842#issuecomment-751443733, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADJRPVNWFEEY2PVMWL4WYQLSW33EJANCNFSM4RIFBLBQ .

javasuns commented 3 years ago

Are you running the dev build? This hasn't been pushed to prod yet. Op zo 27 dec. 2020 10:13 schreef javasuns notifications@github.com: …

Yes, I use the latest “GraalVM CE 21.1.0-dev" release

Wqrld commented 3 years ago

Is AWT support added on windows too? I only tested it on linux which worked correctly.

Java 8, most likely not. For Windows, it turns out that it is a noticeable amount of work. \CC pejovica

fniephaus commented 3 years ago

Windows is not (yet) supported. But it looks like someone is working on it: https://github.com/oracle/graal/pull/3079.

sherl0cks commented 3 years ago

I see that this issue is in the 21.0 milestone, but folks have been testing against 21.1. In which release should we expect this feature?

ghost commented 3 years ago

This should be fixed for the LINUX_AMD64 platform in the latest 20.3 build

This is not fixed on AMD 20.3.

vjovanov commented 3 years ago

@iphorde confirmed, it has been reverted from 20.3 in the last moment due to the complexity of the change. It is merged into 21.0 and will be released soon.

Jire commented 3 years ago

Still getting java.lang.UnsatisfiedLinkError: no awt in java.library.path even with the latest dev build https://github.com/graalvm/graalvm-ce-dev-builds/releases/tag/21.1.0-dev-20210122_0314

flightcrank commented 3 years ago

im getting the issue as well using graal jdk8 21.0 on linux amd64

ondokuzz commented 3 years ago

we get the same problem with graalvm-ce-java8-21.0.0.2. but no problem with graalvm-ce-java11-21.0.0.2.

do we have any workaround for java8?

vjovanov commented 3 years ago

No, there is little reason to support Java 8 for native image as the same code should run on 11 and produce a final executable that behaves equivalently.

mipastgt commented 3 years ago

I still get this error on macOS with graalvm-ce-java11-21.0.0.2. I am a bit confused about the status of this issue.

Exception in thread "JavaFX Application Thread" java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:275)
    at java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.lang.System.loadLibrary(System.java:1871)
    at java.awt.image.ColorModel$1.run(ColorModel.java:209)
    at java.awt.image.ColorModel$1.run(ColorModel.java:207)
    at java.security.AccessController.doPrivileged(AccessController.java:84)
    at java.awt.image.ColorModel.loadLibraries(ColorModel.java:206)
    at java.awt.image.ColorModel.<clinit>(ColorModel.java:219)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at java.awt.image.BufferedImage.<clinit>(BufferedImage.java:287)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at javafx.embed.swing.SwingFXUtils.fromFXImage(SwingFXUtils.java:284)
    at de.mpmediasoft.mpmappane.jfx.map.MapPane.takeSnapshot(MapPane.java:274)
...
scubasoft commented 3 years ago

I am getting the same error as mipastgt with graalvm-ce-java11-21.0.0.2 AND graalvm-ce-java11-21.1.0-dev, on Mac OS.

munishchouhan commented 3 years ago

@scubasoft and @mipastgt we will check it out, please provide the reproducer

scubasoft commented 3 years ago

@mcraj017 Here is the Java code

package awttestforgraal;

import java.awt.*;  
import javax.swing.JFrame;
class First2
{  

    First2()
    {  
        JFrame f=new JFrame();  
        Button b=new Button("click me");  
        b.setBounds(30,50,80,30);  
        f.add(b);  
        f.setSize(300,300);  
        f.setLayout(null);  
        f.setVisible(true);  
    }  

    public static void main(String args[])
    {  
        First2 f=new First2();  
    }
}  

After compiling, it runs fine through Java alone. Then I feed it to native-image like this native-image awttestforgraal.First2 test-awt-image and it goes well. Then I try to run the test-awt-image and get the error

Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:275)
    at java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.lang.System.loadLibrary(System.java:1871)
    at java.awt.Toolkit$3.run(Toolkit.java:1395)
    at java.awt.Toolkit$3.run(Toolkit.java:1393)
    at java.security.AccessController.doPrivileged(AccessController.java:84)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
    at java.awt.Toolkit.<clinit>(Toolkit.java:1425)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at java.awt.Component.<clinit>(Component.java:623)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at awttestforgraal.First2.<init>(First2.java:15)
    at awttestforgraal.First2.main(First2.java:26)

Many thanks in advance.

munishchouhan commented 3 years ago

@scubasoft Please use java tracing agent java -agentlib:native-image-agent=config-output-dir=META-INF/native-image First2 native-image --no-fallback First2

scubasoft commented 3 years ago

@mcraj017 Here is a zip archive of the resulting files after running the tracing agent.

native-image-config.zip

munishchouhan commented 3 years ago

@scubasoft run tracing agent

java -agentlib:native-image-agent=config-output-dir=META-INF/native-image First2
native-image --no-fallback First2

and run native image

native-image --no-fallback First2

it will work

scubasoft commented 3 years ago

@mcraj017 Yes, just like before, the native-image runs fine. But when I run the resulting native image I still get the same error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
    at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:132)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:275)
    at java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.lang.System.loadLibrary(System.java:1871)
    at java.awt.Toolkit$3.run(Toolkit.java:1395)
    at java.awt.Toolkit$3.run(Toolkit.java:1393)
    at java.security.AccessController.doPrivileged(AccessController.java:84)
    at java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
    at java.awt.Toolkit.<clinit>(Toolkit.java:1425)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at java.awt.Component.<clinit>(Component.java:623)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at java.lang.Class.ensureInitialized(DynamicHub.java:530)
    at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:260)
    at awttestforgraal.First2.<init>(First2.java:15)
    at awttestforgraal.First2.main(First2.java:26)
scubasoft commented 3 years ago

@mcraj017 , could this be related to any environment variables that may be set incorrectly?

I also tried the same example without the extra package awttestforgraal, but got the exact same result, just without the mentioning of that package.

scubasoft commented 3 years ago

@mcraj017 Thanks for your previous help and suggestions. I have double checked and reset the PATH and JAVA_HOME variables, and re-run the tracing agent and native-image, but the resulting executable still throws the same error. If this is working fine on your system there must be more variables in play here that is causing this issue.

munishchouhan commented 3 years ago

@scubasoft which operating system you are using?