Closed Rachit-10 closed 2 years ago
Hello,
Can you install the Alpine Freetype package with apk add freetype
and see if that works for you?
Hi,
Yes I have tried doing that and in that case I am getting java.lang.NullPointerException.
Can you share the full NPE when freetype is installed?
I created a simple reproducer without the external dependencies and I had to run apk add freetype fontconfig ttf-dejavu
to get it working. Without fontconfig and the ttf-devavu fonts I would get an NPE.
import java.awt.Font;
import java.awt.GraphicsEnvironment;
public class FontTest {
public static void main(String[] args) {
Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
for (int i = 0; i < fonts.length; i++) {
System.out.println(fonts[i]);
}
}
}
Exception without Fontconfig and ttf-dejavu:
Exception in thread "main" java.lang.NullPointerException
at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
at sun.font.SunFontManager$2.run(SunFontManager.java:441)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.SunFontManager.<init>(SunFontManager.java:386)
at sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at sun.awt.X11FontManager.<init>(X11FontManager.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:190)
at sun.java2d.SunGraphicsEnvironment.getAllFonts(SunGraphicsEnvironment.java:209)
at sun.java2d.HeadlessGraphicsEnvironment.getAllFonts(HeadlessGraphicsEnvironment.java:91)
at FontTest.main(FontTest.java:7)
Yes this patch is working for me now.
Although, I would like to have this library packaged in the standard image provided by the corretto. This is because let's say if I upgrade the image version in the future, i would have to manually make these patches through the Dockerfile. Also I have a software which I provide to customers and they would also have to do these patches in case of any upgrade. So I would like to have these libraries be a part of the standard image provided by the corretto itself.
Closing this in lieu of feature request: https://github.com/corretto/corretto-docker/issues/112
Describe the bug
The docker image corretto:8-alpine-jdk is being used to build a Maven Application and during the build process I am encountering an error that libfreetype.so.6 is missing. This library is being called by the Apache POI.
To Reproduce
Environment: Alpine / Java 8 / Spring boot 2.1.x Jib a spring boot 2.1.x app that uses the autoSizeColumn feature of apache-poi and attempt to run the container on your local docker.
OR
Run the following Java Code Snippet:
Following dependencies would be required too:
Screenshots
Error Message
Lib Directory
Platform information
Additional context
Log output