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

UnsatisfiedLinkError: No awt in java.library.path #8273

Closed
tabiStein opened this issue Jan 29, 2024 · 8 comments
Closed

UnsatisfiedLinkError: No awt in java.library.path #8273

tabiStein opened this issue Jan 29, 2024 · 8 comments
Assignees

Comments

@tabiStein
Copy link

Describe the issue
Note: This is a reproduction of issue #2842 , as requested by @vjovanov. That issue had been marked as complete, but many users (including I) have continued to experience it -- so, vjovanov said: "to get this fixed it would be best to open a new ticket for this problem with a minimal reproducer".

Essentially, when attempting to load a class from the awt library in a native image, the titular exception occurs.

Steps to reproduce the issue

  1. Please check out the following project for a small, single-class repro of this error: reproduce-awt-lib-error-graal
  2. Run mvn clean install in the root directory of the project to build the jar
  3. Run mvn -Pnative package to build the native image, called test/repro-awt-lib-error
  4. Run docker run test/repro-awt-lib-error

Describe GraalVM and your environment:

  • GraalVM version 23.0.2 (as determined by buildpack)
  • JDK major version: 17
  • OS: MacOS Sonoma 14.2.1
  • Architecture: 6-Core Intel Core i9
  • Maven version: 3.9.6
  • Docker version: 24.0.7

More details
The output printed from my enviroment, finishing with the error stack trace, is as follows:

docker run test/repro-awt-lib-error:latest

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.0)

2024-01-29T16:02:51.618Z  INFO 1 --- [           main] org.example.App                          : Starting AOT-processed App using Java 17.0.9 with PID 1 (/workspace/org.example.App started by cnb in /workspace)
2024-01-29T16:02:51.619Z  INFO 1 --- [           main] org.example.App                          : No active profile set, falling back to 1 default profile: "default"
2024-01-29T16:02:51.625Z  INFO 1 --- [           main] org.example.App                          : Started App in 0.014 seconds (process running for 0.017)
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 java.base@17.0.9/java.lang.ClassLoader.loadLibrary(ClassLoader.java:50)
	at java.base@17.0.9/java.lang.Runtime.loadLibrary0(Runtime.java:818)
	at java.base@17.0.9/java.lang.System.loadLibrary(System.java:1989)
	at java.desktop@17.0.9/java.awt.image.ColorModel$1.run(ColorModel.java:210)
	at java.desktop@17.0.9/java.awt.image.ColorModel$1.run(ColorModel.java:208)
	at java.base@17.0.9/java.security.AccessController.executePrivileged(AccessController.java:173)
	at java.base@17.0.9/java.security.AccessController.doPrivileged(AccessController.java:318)
	at java.desktop@17.0.9/java.awt.image.ColorModel.loadLibraries(ColorModel.java:207)
	at java.desktop@17.0.9/java.awt.image.ColorModel.<clinit>(ColorModel.java:220)
	at java.desktop@17.0.9/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)
@vjovanov
Copy link
Member

Thank you greatly for the concise reproducer! Assigning it to @pejovica as he is providing support for AWT.

@pejovica
Copy link
Member

@tabiStein Is libawt.so next to the built executable? If not, was it listed in the build output as a produced artifact?

@tabiStein
Copy link
Author

@pejovica No, the executable is alone in a workspace/ directory.
image

Yes, I do see libawt.so listed in the built artifacts:
[INFO] [creator] Produced artifacts:
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt_headless.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libawt_xawt.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libfontmanager.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libfreetype.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjava.so (jdk_library_shim)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjavajpeg.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/libjvm.so (jdk_library_shim)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/liblcms.so (jdk_library)
[INFO] [creator] /layers/paketo-buildpacks_native-image/native-image/org.example.App (executable)

I've attached the full output of running mvn -Pnative package, so you can check it in detail:
packageOutput.txt

@pejovica
Copy link
Member

No, the executable is alone in a workspace/ directory.

Well, that's the problem. All produced artifacts are necessary for the executable to work (i.e., it can't work without the listed shared libraries).

Since the build output shows that all required artifacts are produced, and the error corresponds to the fact that the shared libraries are indeed missing when running the executable, there is nothing to fix on the native image side.

I'm guessing this is a bug with what drives the native-image as it doesn't seem to take into account all the artifacts produced by the build.

@tabiStein
Copy link
Author

tabiStein commented Jan 30, 2024

Thanks for the insight @pejovica , I have created a new issue with the Paketo team to see if it's an issue with their buildpack. Paketo Issue 427

If it's alright with you, I would like to keep this issue open until we can identify and verify the fix.

@fniephaus fniephaus assigned tabiStein and unassigned pejovica Jan 30, 2024
@fniephaus
Copy link
Member

@tabiStein sure, I hope you don't mind that I've re-assigned the ticket to you. Please update the ticket when paketo-buildpacks/native-image#308 is resolved.

@nilseckert
Copy link

@tabiStein The Ticket paketo-buildpacks/native-image#308 has been closed recently.

jagodevreede added a commit to jagodevreede/sdkman-ui that referenced this issue Aug 26, 2024
@tabiStein
Copy link
Author

@tabiStein The Ticket paketo-buildpacks/native-image#308 has been closed recently.

Thanks Nils, my team deprioritized the native image work due to this issue so I haven't been keeping up-to-date. I'll close the ticket.

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

6 participants