Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no awt in java.library.path #2842

Closed
abamoshe opened this issue Sep 11, 2020 · 78 comments
Closed

no awt in java.library.path #2842

abamoshe opened this issue Sep 11, 2020 · 78 comments
Assignees
Milestone

Comments

@abamoshe
Copy link

abamoshe commented Sep 11, 2020

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 #2363 (comment)
i'v also downloaded the dev version to avoid this #2363 (comment))

@munishchouhan
Copy link
Contributor

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

@abamoshe
Copy link
Author

abamoshe commented Sep 14, 2020

@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 (#2363 (comment)) and then run the compiled exe

@abamoshe
Copy link
Author

@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
Copy link
Contributor

@abamoshe thanks for the reproducer

@cstancu cstancu assigned vjovanov and unassigned cstancu Sep 23, 2020
@mpela81
Copy link

mpela81 commented Oct 1, 2020

Having the same issue here with SystemTray.getSystemTray()

@emrul
Copy link

emrul commented Oct 15, 2020

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
Copy link

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

@vjovanov
Copy link
Member

vjovanov commented Nov 5, 2020

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

@fniephaus
Copy link
Member

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
Copy link

mpela81 commented Nov 11, 2020

And what about Windows?

@vjovanov
Copy link
Member

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
Copy link

jayanmn commented Nov 18, 2020

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
Copy link

Skhmt commented Nov 18, 2020

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
Copy link

@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
Copy link
Collaborator

zakkak commented Nov 20, 2020

FWIW in Mandrel we had to backport 5d2997a to 20.3 to get a similar case resolved

@sherl0cks
Copy link

sherl0cks commented Nov 20, 2020

@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
Copy link
Collaborator

zakkak commented Nov 20, 2020

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

@sherl0cks
Copy link

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

@vjovanov
Copy link
Member

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.

@vjovanov vjovanov added this to the 21.0 milestone Nov 20, 2020
atextor added a commit to bci-oss/esmf-sdk that referenced this issue Feb 1, 2023
@maomaochong2dai
Copy link

windows GraalVM 22.3.1 jdk17 Still getting java.lang.UnsatisfiedLinkError: no awt in java.library.path

@javasuns
Copy link

javasuns commented Feb 2, 2023

windows GraalVM 22.3.1 jdk17 Still getting java.lang.UnsatisfiedLinkError: no awt in java.library.path

Tried it also on MacOS x86 and indeed issue persists.

@javasuns
Copy link

windows GraalVM 22.3.1 jdk17 Still getting java.lang.UnsatisfiedLinkError: no awt in java.library.path

I am verifying that I am getting the error on Windows 10 as well

@GenCloud
Copy link

windows GraalVM 22.3.1 jdk17 Still getting java.lang.UnsatisfiedLinkError: no awt in java.library.path

I am verifying that I am getting the error on Windows 10 as well

any news for hook awt with javafx on windows, maybe has other way for include this libs on native exe bundle?

@oldshensheep
Copy link

@GenCloud @javasuns
Have you run tracing agent to collect Metadata config? https://www.graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/
The most important point is to execute as many paths as possible in the code when the tracing agent is running
I have the same issue, but after using tracing agent collected Metadata config, it was working.

@gmseed
Copy link

gmseed commented Jul 29, 2023

It's July 2023 and I've just built/run a simple Swing app that uses the SystemTray on Linux and getting the [java.lang.UnsatisfiedLinkError: no awt in java.library.path] error when I run the GraalVM executable. I'm using graalvm-jdk-17.0.7+8.1 on Linux Mint 21. I see comments that this is fixed on Linux, but have my doubts about that.

And yes, prior to running the native-image I ran [-agentlib:native-image-agent=config-output-dir]. When I look into the reflect-config.json config file I don't see any reference to the awt toolkit or system tray.

$ ./app
Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at [email protected]/java.lang.System.loadLibrary(System.java:1989)
at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1388)
at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1386)
at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:171)
at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
at [email protected]/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
at [email protected]/java.awt.Toolkit.initStatic(Toolkit.java:1423)
at [email protected]/java.awt.Toolkit.(Toolkit.java:1397)
at app.main(qisMain.java:119)

In addition, I created the most minimal JavaFX app using [https://start.gluon.io/] and then fed it into GraalVM after creating the agent config files. Again, it built OK but at runtime:

Exception in thread "main" java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:278)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:679)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
at [email protected]/java.lang.Thread.run(Thread.java:833)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:807)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:210)

@robozb
Copy link

robozb commented Aug 4, 2023

I experienced this as well when a try to run a Spring Boot 3 into GraalVM docker image on Win10.

java.lang.UnsatisfiedLinkError: no awt in java.library.path
        at com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136) ~[na:na]
        at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50) ~[hu.wfs.vsm.ManagerApplication:na]
        at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:818) ~[na:na]
        at [email protected]/java.lang.System.loadLibrary(System.java:1989) ~[na:na]
        at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1388) ~[na:na]
        at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1386) ~[na:na]
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:171) ~[na:na]
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
        at [email protected]/java.awt.Toolkit.loadLibraries(Toolkit.java:1385) ~[hu.wfs.vsm.ManagerApplication:na]
        at [email protected]/java.awt.Toolkit.initStatic(Toolkit.java:1423) ~[hu.wfs.vsm.ManagerApplication:na]
        at [email protected]/java.awt.Toolkit.<clinit>(Toolkit.java:1397) ~[hu.wfs.vsm.ManagerApplication:na]
        at [email protected]/java.awt.Color.<clinit>(Color.java:277) ~[hu.wfs.vsm.ManagerApplication:na]
        at net.bull.javamelody.internal.model.JRobin.<clinit>(JRobin.java:71) ~[na:na]
        at net.bull.javamelody.FilterContext.initCollect(FilterContext.java:271) ~[na:na]
        at net.bull.javamelody.FilterContext.<init>(FilterContext.java:137) ~[na:na]
        at net.bull.javamelody.MonitoringFilter.init(MonitoringFilter.java:145) ~[hu.wfs.vsm.ManagerApplication:2.0.0]
        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:263) ~[na:na]
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:102) ~[na:na]
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4309) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4922) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) ~[na:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) ~[na:na]
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[hu.wfs.vsm.ManagerApplication:na]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[na:na]
        at [email protected]/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[hu.wfs.vsm.ManagerApplication:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:846) ~[na:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1328) ~[na:na]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1318) ~[na:na]
        at [email protected]/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[hu.wfs.vsm.ManagerApplication:na]
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) ~[na:na]
        at [email protected]/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) ~[hu.wfs.vsm.ManagerApplication:na]
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:866) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:241) ~[na:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:428) ~[na:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:918) ~[na:na]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:485) ~[hu.wfs.vsm.ManagerApplication:10.1.11]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:123) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:489) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602) ~[hu.wfs.vsm.ManagerApplication:6.0.11]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27) ~[hu.wfs.vsm.ManagerApplication:na]

2023-08-04T08:50:24.077Z ERROR 1 --- [           main] o.apache.catalina.core.StandardContext   : One or more Filters failed to start. Full details will be found in the appropriate container log file
2023-08-04T08:50:24.078Z ERROR 1 --- [           main] o.apache.catalina.core.StandardContext   : Context [] startup failed due to previous errors
2023-08-04T08:50:24.084Z  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2023-08-04T08:50:24.085Z  WARN 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server
2023-08-04T08:50:24.086Z ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602) ~[hu.wfs.vsm.ManagerApplication:6.0.11]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at hu.wfs.vsm.ManagerApplication.main(ManagerApplication.java:27) ~[hu.wfs.vsm.ManagerApplication:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:142) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:104) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:489) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:211) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        ... 8 common frames omitted
Caused by: java.lang.IllegalStateException: StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.rethrowDeferredStartupExceptions(TomcatWebServer.java:187) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:126) ~[hu.wfs.vsm.ManagerApplication:3.1.2]
        ... 13 common frames omitted

My dependency tree:

--- maven-dependency-plugin:3.5.0:tree (default-cli) @ vsm-backend ---
hu.wfs.vau:vsm-backend:jar:0.0.11-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-web:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter:jar:3.1.2:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.1.2:compile
|  |  |  +- ch.qos.logback:logback-classic:jar:1.4.8:compile
|  |  |  |  \- ch.qos.logback:logback-core:jar:1.4.8:compile
|  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.20.0:compile
|  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.20.0:compile
|  |  |  \- org.slf4j:jul-to-slf4j:jar:2.0.7:compile
|  |  +- jakarta.annotation:jakarta.annotation-api:jar:2.1.1:compile
|  |  \- org.yaml:snakeyaml:jar:1.33:compile
|  +- org.springframework.boot:spring-boot-starter-json:jar:3.1.2:compile
|  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.15.2:compile
|  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.15.2:compile
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:3.1.2:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:10.1.11:compile
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:10.1.11:compile
|  +- org.springframework:spring-web:jar:6.0.11:compile
|  |  \- org.springframework:spring-beans:jar:6.0.11:compile
|  \- org.springframework:spring-webmvc:jar:6.0.11:compile
|     +- org.springframework:spring-context:jar:6.0.11:compile
|     \- org.springframework:spring-expression:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-devtools:jar:3.1.2:runtime
|  +- org.springframework.boot:spring-boot:jar:3.1.2:compile
|  \- org.springframework.boot:spring-boot-autoconfigure:jar:3.1.2:compile
+- org.springframework.boot:spring-boot-starter-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test:jar:3.1.2:test
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.1.2:test
|  +- com.jayway.jsonpath:json-path:jar:2.8.0:test
|  +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0:compile
|  |  \- jakarta.activation:jakarta.activation-api:jar:2.1.2:compile
|  +- net.minidev:json-smart:jar:2.4.11:test
|  |  \- net.minidev:accessors-smart:jar:2.4.11:test
|  |     \- org.ow2.asm:asm:jar:9.3:compile
|  +- org.assertj:assertj-core:jar:3.24.2:test
|  |  \- net.bytebuddy:byte-buddy:jar:1.14.5:runtime
|  +- org.hamcrest:hamcrest:jar:2.2:test
|  +- org.junit.jupiter:junit-jupiter:jar:5.9.3:test
|  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.9.3:test
|  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
|  |  |  +- org.junit.platform:junit-platform-commons:jar:1.9.3:test
|  |  |  \- org.apiguardian:apiguardian-api:jar:1.1.2:test
|  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.9.3:test
|  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.9.3:test
|  |     \- org.junit.platform:junit-platform-engine:jar:1.9.3:test
|  +- org.mockito:mockito-core:jar:5.3.1:test
|  |  +- net.bytebuddy:byte-buddy-agent:jar:1.14.5:test
|  |  \- org.objenesis:objenesis:jar:3.3:test
|  +- org.mockito:mockito-junit-jupiter:jar:5.3.1:test
|  +- org.skyscreamer:jsonassert:jar:1.5.1:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- org.springframework:spring-core:jar:6.0.11:compile
|  |  \- org.springframework:spring-jcl:jar:6.0.11:compile
|  +- org.springframework:spring-test:jar:6.0.11:test
|  \- org.xmlunit:xmlunit-core:jar:2.9.1:test
+- net.bull.javamelody:javamelody-spring-boot-starter:jar:2.0.0:compile
|  +- net.bull.javamelody:javamelody-core:jar:2.0.0:compile
|  |  \- org.jrobin:jrobin:jar:1.5.9:compile
|  \- org.springframework.boot:spring-boot-starter-aop:jar:3.1.2:compile
|     \- org.aspectj:aspectjweaver:jar:1.9.19:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-starter-jdbc:jar:3.1.2:compile
|  |  +- com.zaxxer:HikariCP:jar:5.0.1:compile
|  |  \- org.springframework:spring-jdbc:jar:6.0.11:compile
|  +- org.hibernate.orm:hibernate-core:jar:6.2.6.Final:compile
|  |  +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0:compile
|  |  +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1:compile
|  |  +- org.jboss.logging:jboss-logging:jar:3.5.3.Final:compile
|  |  +- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final:runtime
|  |  +- io.smallrye:jandex:jar:3.0.5:runtime
|  |  +- com.fasterxml:classmate:jar:1.5.1:compile
|  |  +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.3:compile
|  |  |  \- org.glassfish.jaxb:jaxb-core:jar:4.0.3:compile
|  |  |     +- org.eclipse.angus:angus-activation:jar:2.0.1:runtime
|  |  |     +- org.glassfish.jaxb:txw2:jar:4.0.3:compile
|  |  |     \- com.sun.istack:istack-commons-runtime:jar:4.1.2:compile
|  |  +- jakarta.inject:jakarta.inject-api:jar:2.0.1:runtime
|  |  \- org.antlr:antlr4-runtime:jar:4.10.1:compile
|  +- org.springframework.data:spring-data-jpa:jar:3.1.2:compile
|  |  +- org.springframework.data:spring-data-commons:jar:3.1.2:compile
|  |  +- org.springframework:spring-orm:jar:6.0.11:compile
|  |  \- org.springframework:spring-tx:jar:6.0.11:compile
|  \- org.springframework:spring-aspects:jar:6.0.11:compile
+- org.springframework.boot:spring-boot-starter-security:jar:3.1.2:compile
|  +- org.springframework:spring-aop:jar:6.0.11:compile
|  +- org.springframework.security:spring-security-config:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-web:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-validation:jar:3.1.2:compile
|  +- org.apache.tomcat.embed:tomcat-embed-el:jar:10.1.11:compile
|  \- org.hibernate.validator:hibernate-validator:jar:8.0.1.Final:compile
|     \- jakarta.validation:jakarta.validation-api:jar:3.0.2:compile
+- org.springframework.security:spring-security-test:jar:6.1.2:test
|  \- org.springframework.security:spring-security-core:jar:6.1.2:compile
|     \- org.springframework.security:spring-security-crypto:jar:6.1.2:compile
+- org.springframework.boot:spring-boot-starter-oauth2-resource-server:jar:3.1.2:compile
|  +- org.springframework.security:spring-security-oauth2-resource-server:jar:6.1.2:compile
|  |  \- org.springframework.security:spring-security-oauth2-core:jar:6.1.2:compile
|  \- org.springframework.security:spring-security-oauth2-jose:jar:6.1.2:compile
|     \- com.nimbusds:nimbus-jose-jwt:jar:9.31:compile
|        \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:3.1.2:compile
|  \- org.thymeleaf:thymeleaf-spring6:jar:3.1.1.RELEASE:compile
|     \- org.thymeleaf:thymeleaf:jar:3.1.1.RELEASE:compile
|        +- org.attoparser:attoparser:jar:2.0.6.RELEASE:compile
|        \- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
+- org.thymeleaf.extras:thymeleaf-extras-springsecurity6:jar:3.1.1.RELEASE:compile
|  \- org.slf4j:slf4j-api:jar:2.0.7:compile
+- org.springframework.boot:spring-boot-starter-actuator:jar:3.1.2:compile
|  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:3.1.2:compile
|  |  \- org.springframework.boot:spring-boot-actuator:jar:3.1.2:compile
|  +- io.micrometer:micrometer-observation:jar:1.11.2:compile
|  |  \- io.micrometer:micrometer-commons:jar:1.11.2:compile
|  \- io.micrometer:micrometer-core:jar:1.11.2:compile
|     +- org.hdrhistogram:HdrHistogram:jar:2.1.12:runtime
|     \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
+- com.sun.mail:javax.mail:jar:1.6.2:compile
|  \- javax.activation:activation:jar:1.1:compile
+- org.passay:passay:jar:1.6.3:compile
+- com.sun.activation:jakarta.activation:jar:2.0.0:compile
+- hu.wfs.lib.halozat:WFSLib_Halozat:jar:2.7.0:compile
|  +- hu.wfs.lib.biztonsag:WFSLib_Biztonsag:jar:2.5.3:compile
|  |  +- hu.wfs.lib.altalanos:WFSLib_Altalanos:jar:2.7.2:compile
|  |  |  +- org.apache.velocity:velocity:jar:1.5:compile
|  |  |  |  +- commons-collections:commons-collections:jar:3.1:compile
|  |  |  |  +- commons-lang:commons-lang:jar:2.1:compile
|  |  |  |  \- oro:oro:jar:2.0.8:compile
|  |  |  +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile
|  |  |  +- org.apache.poi:poi:jar:3.17:compile
|  |  |  |  \- org.apache.commons:commons-collections4:jar:4.1:compile
|  |  |  +- org.apache.poi:poi-ooxml:jar:3.17:compile
|  |  |  |  +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
|  |  |  |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
|  |  |  |  |     \- stax:stax-api:jar:1.0.1:compile
|  |  |  |  \- com.github.virtuald:curvesapi:jar:1.04:compile
|  |  |  +- com.sun.xml.bind:jaxb-core:jar:4.0.3:compile
|  |  |  \- com.sun.xml.bind:jaxb-impl:jar:4.0.3:compile
|  |  +- kulsojar.bcprov_jdk16_jeloletlen_1_43:bcprov_jdk16_jeloletlen_1_43:jar:1.0.0:compile
|  |  +- ch.ethz.ganymed:ganymed-ssh2:jar:build210:compile
|  |  +- J2SSHCommon:J2SSHCommon:jar:0.2.9-patched:system
|  |  +- J2SSHCore:J2SSHCore:jar:0.2.9-patched:system
|  |  +- commons-httpclient:commons-httpclient:jar:3.0.1:compile
|  |  \- commons-logging:commons-logging:jar:1.0.4:compile
|  +- javax.mail:javax.mail-api:jar:1.6.2:compile
|  +- javax.xml.ws:jaxws-api:jar:2.3.1:compile
|  |  +- javax.xml.bind:jaxb-api:jar:2.3.1:compile
|  |  |  \- javax.activation:javax.activation-api:jar:1.2.0:compile
|  |  +- javax.xml.soap:javax.xml.soap-api:jar:1.4.0:compile
|  |  \- javax.annotation:javax.annotation-api:jar:1.3.2:compile
|  \- org.jsoup:jsoup:jar:1.13.1:compile
+- org.projectlombok:lombok:jar:1.18.28:compile
+- org.keycloak:keycloak-admin-client:jar:21.0.1:compile
|  +- org.keycloak:keycloak-core:jar:21.0.1:compile
|  +- org.keycloak:keycloak-common:jar:21.0.1:compile
|  +- org.jboss.resteasy:resteasy-client:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-client-api:jar:4.7.7.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core-spi:jar:4.7.7.Final:compile
|  |  |  \- org.jboss.spec.javax.annotation:jboss-annotations-api_1.3_spec:jar:2.0.1.Final:compile
|  |  +- org.jboss.resteasy:resteasy-core:jar:4.7.7.Final:compile
|  |  |  +- com.ibm.async:asyncutil:jar:0.1.0:compile
|  |  |  \- io.smallrye.config:smallrye-config:jar:2.3.0:compile
|  |  |     \- io.smallrye.config:smallrye-config-core:jar:2.3.0:compile
|  |  |        +- org.eclipse.microprofile.config:microprofile-config-api:jar:2.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-annotation:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-expression:jar:1.6.0:compile
|  |  |        |  \- io.smallrye.common:smallrye-common-function:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-constraint:jar:1.6.0:compile
|  |  |        +- io.smallrye.common:smallrye-common-classloader:jar:1.6.0:compile
|  |  |        \- io.smallrye.config:smallrye-config-common:jar:2.3.0:compile
|  |  +- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
|  |  |  \- org.apache.httpcomponents:httpcore:jar:4.4.16:compile
|  |  +- commons-codec:commons-codec:jar:1.15:compile
|  |  +- commons-io:commons-io:jar:2.9.0:compile
|  |  +- org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.1_spec:jar:2.0.1.Final:compile
|  |  \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
|  +- org.jboss.resteasy:resteasy-multipart-provider:jar:4.7.7.Final:compile
|  |  +- com.sun.mail:jakarta.mail:jar:1.6.5:compile
|  |  +- org.apache.james:apache-mime4j-dom:jar:0.8.3:compile
|  |  |  \- org.apache.james:apache-mime4j-core:jar:0.8.3:compile
|  |  \- org.apache.james:apache-mime4j-storage:jar:0.8.3:compile
|  +- org.jboss.resteasy:resteasy-jackson2-provider:jar:4.7.7.Final:compile
|  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.15.2:compile
|  |  |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.15.2:compile
|  |  |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.15.2:compile
|  |  \- com.github.java-json-tools:json-patch:jar:1.13:compile
|  |     +- com.github.java-json-tools:msg-simple:jar:1.2:compile
|  |     |  \- com.github.java-json-tools:btf:jar:1.3:compile
|  |     \- com.github.java-json-tools:jackson-coreutils:jar:2.0:compile
|  \- org.jboss.resteasy:resteasy-jaxb-provider:jar:4.7.7.Final:compile
|     \- org.jboss.spec.javax.xml.bind:jboss-jaxb-api_2.3_spec:jar:2.0.0.Final:compile
+- com.mysql:mysql-connector-j:jar:8.0.33:runtime
+- io.micrometer:micrometer-registry-prometheus:jar:1.11.2:compile
|  \- io.prometheus:simpleclient_common:jar:0.16.0:compile
|     \- io.prometheus:simpleclient:jar:0.16.0:compile
|        +- io.prometheus:simpleclient_tracer_otel:jar:0.16.0:compile
|        |  \- io.prometheus:simpleclient_tracer_common:jar:0.16.0:compile
|        \- io.prometheus:simpleclient_tracer_otel_agent:jar:0.16.0:compile
+- com.github.javafaker:javafaker:jar:1.0.2:compile
|  +- org.apache.commons:commons-lang3:jar:3.12.0:compile
|  +- org.yaml:snakeyaml:jar:android:1.23:compile
|  \- com.github.mifmif:generex:jar:1.0.2:compile
|     \- dk.brics.automaton:automaton:jar:1.11-8:compile
+- org.modelmapper:modelmapper:jar:3.0.0:compile
+- com.fasterxml.jackson.core:jackson-databind:jar:2.15.2:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.15.2:compile
|  \- com.fasterxml.jackson.core:jackson-core:jar:2.15.2:compile
\- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.15.2:compile

@chiralsoftware
Copy link

I'm having the exact same issue here, graalvm-jdk-20.0.2+9.1 on Ubuntu 20.04.6, with a Spring Boot native app.

@gmseed
Copy link

gmseed commented Aug 8, 2023

It would be nice to have a series of really detailed simple examples/tutorials that worked with AWT/Swing on Win/Lin/Mac, if it is indeed supported. I see a hello-world example on GraalVM's website but how about one that writes hello-world into a Swing dialog. To build it do we have to set the application to headless mode or not? If we set it to headless what are the downstream implications of this when it comes to loading the awt toolkit, a simple application that draws on the system-tray class, apps with and without the Maven plugin, etc, etc. Because I don't think this area is well covered and certainly not well documented. AWT/Swing is either supported or it is not and if it is then needs it needs detailed instructions of how to get it working. I've spent some time trying to get the most basic application to first build and then run and still no closer. Thus, I've had to give up.

@InsouciantQualms
Copy link

See the same on graalvm-jdk-20.0.2+9.1 with MacOS Sonoma running on an Intel chipset.

@saugion
Copy link

saugion commented Nov 11, 2023

Same issue with java 21 and spring boot 3 :(

@PavelBortnovskyi
Copy link

PavelBortnovskyi commented Nov 16, 2023

Got: No awt in java.library.path at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java
with Java 21, SpringBoot 3.1.4 and container-registry.oracle.com/graalvm/native-image:21.0.1-ol8 AS builder.

Which version of native-image I can try to run very simple code like this in native-image:
package com.neo.crypto_bot.service;

import ij.IJ;
import ij.ImagePlus;
import ij.process.ImageProcessor;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.api.objects.InputFile;

import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;

@component
public class ImageFactory {

private final List<String> backgrounds = List.of(
        "src\\main\\resources\\Images\\background1.jpg",
        "src\\main\\resources\\Images\\background2.jpg"
);

public InputFile createImageWithText(String text, int fontSize, int backgroundNumber) throws IOException {
    ImagePlus image = IJ.openImage(backgrounds.get(backgroundNumber));
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ImageProcessor ip = image.getProcessor();

    Font font = new Font(Font.MONOSPACED, Font.BOLD, fontSize);
    ip.setFont(font);
    ip.setColor(Color.WHITE);
    FontMetrics fontMetrics = ip.getFontMetrics();
    int charWidth = fontMetrics.charWidth('A');

    String[] lines = text.split("\n");
    int x = 20;
    int y = ip.getFontMetrics().getHeight();
    for (String line : lines) {
        if (line.contains("(")) {
            String[] subLines = line.split("\\(");
            ip.drawString(subLines[0], x, y += ip.getFontMetrics().getHeight());
            if (subLines[1].contains("-")) ip.setColor(Color.RED);
            else {
                ip.setColor(Color.GREEN);
            }
            ip.drawString("(" + subLines[1], x + charWidth * subLines[0].length(), y);
            ip.setColor(Color.WHITE);
        } else ip.drawString(line, 30, y += ip.getFontMetrics().getHeight() + 20);
    }
    try {
        ImageIO.write(ip.getBufferedImage(), "jpg", outputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return new InputFile(new ByteArrayInputStream(outputStream.toByteArray()), "prices.jpg");
}

}

@shireeshakalle
Copy link

Hello ,

Still I'm facing the same issue
Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:120)
at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at [email protected]/java.lang.System.loadLibrary(System.java:1989)
at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1388)
at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1386)
at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168)
at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
at [email protected]/java.awt.Toolkit.loadLibraries(Toolkit.java:1385)
at [email protected]/java.awt.Toolkit.initStatic(Toolkit.java:1423)
at [email protected]/java.awt.Toolkit.(Toolkit.java:1397)
at [email protected]/javax.swing.UIManager.(UIManager.java:389)
at [email protected]/javax.swing.filechooser.WindowsFileSystemView.(FileSystemView.java:842)
at [email protected]/javax.swing.filechooser.FileSystemView.getFileSystemView(FileSystemView.java:86)

I'm using java17 and graalvm-ce-java17-22.3.0 version .can any one tell me is this issue fixed ?if yes please help me to solve the issue.

@vjovanov vjovanov removed their assignment Nov 24, 2023
@PavelBortnovskyi
Copy link

Hello ,

Still I'm facing the same issue Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:120) at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50) at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:818) at [email protected]/java.lang.System.loadLibrary(System.java:1989) at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1388) at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1386) at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:168) at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318) at [email protected]/java.awt.Toolkit.loadLibraries(Toolkit.java:1385) at [email protected]/java.awt.Toolkit.initStatic(Toolkit.java:1423) at [email protected]/java.awt.Toolkit.(Toolkit.java:1397) at [email protected]/javax.swing.UIManager.(UIManager.java:389) at [email protected]/javax.swing.filechooser.WindowsFileSystemView.(FileSystemView.java:842) at [email protected]/javax.swing.filechooser.FileSystemView.getFileSystemView(FileSystemView.java:86)

I'm using java17 and graalvm-ce-java17-22.3.0 version .can any one tell me is this issue fixed ?if yes please help me to solve the issue.

You can try to use Liberica NIK based on GraalVM: https://bell-sw.com/blog/how-to-turn-awt-applications-into-native-images/
But from my case I am just getting another errors and still can`t run my app in native image with some graphics libraries.

@NicklasWallgren
Copy link

NicklasWallgren commented Jan 7, 2024

Still an issue using GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19).

Could you please re-open this issue @vjovanov 🙂

16:03:31.422 [tomcat-handler-5] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] transactionId:  traceId:  - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.UnsatisfiedLinkError: No awt in java.library.path] with root cause
java.lang.UnsatisfiedLinkError: No awt in java.library.path
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
        at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:106)
        at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:916)
        at [email protected]/java.lang.System.loadLibrary(System.java:2059)
        at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1384)
        at [email protected]/java.awt.Toolkit$2.run(Toolkit.java:1382)
        at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:129)
        at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:319)
        at [email protected]/java.awt.Toolkit.loadLibraries(Toolkit.java:1381)
        at [email protected]/java.awt.Toolkit.initStatic(Toolkit.java:1419)
        at [email protected]/java.awt.Toolkit.<clinit>(Toolkit.java:1393)
        at [email protected]/java.awt.Color.<clinit>(Color.java:277)
        at org.xhtmlrenderer.pdf.ITextOutputDevice.<init>(ITextOutputDevice.java:116)
        at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:108)
        at org.xhtmlrenderer.pdf.ITextRenderer.<init>(ITextRenderer.java:100)

@vjovanov
Copy link
Member

vjovanov commented Jan 8, 2024

@NicklasWallgren to get this fixed it would be best to open a new ticket for this problem with a minimal reproducer.

@tabiStein
Copy link

Hi @vjovanov , I created a super tiny project reproduce-awt-lib-error-graal reproducing this error. There's only one class (copy-pasted below). Does this look useful? If so, I will open a new ticket.

@SpringBootApplication
public class App {

  public static void main(String[] args) throws IOException {
    SpringApplication.run(App.class, args);
    File inputPdf = new File("TestPdf.pdf");

    /* In the native image, this line throws "java.lang.UnsatisfiedLinkError: no awt in java.library.path" */
    PDDocument document = PDDocument.load(inputPdf);
  }

} 

Stack trace:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path
	at org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk.NativeLibrarySupport.loadLibraryRelative(NativeLibrarySupport.java:136)
	at [email protected]/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
	at [email protected]/java.lang.Runtime.loadLibrary0(Runtime.java:818)
	at [email protected]/java.lang.System.loadLibrary(System.java:1989)
	at [email protected]/java.awt.image.ColorModel$1.run(ColorModel.java:210)
	at [email protected]/java.awt.image.ColorModel$1.run(ColorModel.java:208)
	at [email protected]/java.security.AccessController.executePrivileged(AccessController.java:173)
	at [email protected]/java.security.AccessController.doPrivileged(AccessController.java:318)
	at [email protected]/java.awt.image.ColorModel.loadLibraries(ColorModel.java:207)
	at [email protected]/java.awt.image.ColorModel.<clinit>(ColorModel.java:220)
	at [email protected]/java.awt.image.Raster.<clinit>(Raster.java:172)
	at org.apache.pdfbox.pdmodel.PDDocument.<clinit>(PDDocument.java:107)
	at org.example.App.main(App.java:17)

@saugion
Copy link

saugion commented Jan 27, 2024

Hi @tabiStein, any news? Thanks

@tabiStein
Copy link

Hi @tabiStein, any news? Thanks

I never heard back from @vjovanov, but since my post got several upvotes I just created the new issue here: #8273

@vjovanov
Copy link
Member

@pejovica is in charge of this ticket, so I left the response to him. It seems it fell through the cracks so sorry for the delay.

@dlevi-cs
Copy link

Hey, Any news on that, it's really a blocker for us

@tabiStein
Copy link

@dlevi-cs If you click into the linked ticket I added a few posts ago, it's looking like it's a Paketo problem (linked to my ticket). They've marked it as an enhancement. Feel free to comment on that issue -- I think the Graal team has already done all they can on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests