简体   繁体   English

无法初始化类 sun.awt.X11FontManager alpine java 17

[英]Could not initialize class sun.awt.X11FontManager alpine java 17

We're trying to run our java 8 application inside alpine_java-17 container.我们正在尝试在 alpine_java-17 容器中运行我们的 java 8 应用程序。 Everything compiles and works fine except one thing.除了一件事,一切都可以编译并正常工作。

One functionality regarding excel doesn't work.关于 excel 的一项功能不起作用。 In the logs I found:在我发现的日志中:

Could not initialize class sun.awt.X11FontManager

Previously when we ran our app inside java8 container we didn't have this issue since we had command to install required packages:以前,当我们在 java8 容器中运行我们的应用程序时,我们没有遇到这个问题,因为我们有安装所需软件包的命令:

RUN apt-get install -y fontconfig libfreetype6

But now since we have alpine 17 we changed the above command to但是现在由于我们有 alpine 17,我们将上面的命令更改为

RUN apk add fontconfig
RUN apk add freetype

I tried to install libfreetype6 using RUN apk add libfreetype6 but docker returned me an error:我尝试使用 RUN apk add libfreetype6 安装 libfreetype6 但 docker 给我返回了一个错误:

ERROR: unable to select packages:
  libfreetype6 (no such package):
    required by: world[libfreetype6]
Error response from daemon: The command '/bin/sh -c apk add libfreetype6' returned a non-zero code: 1

It seems like freetype is not the same as libfreetype6, but libfreetype6 is missing.似乎 freetype 与 libfreetype6 不同,但缺少 libfreetype6。

Can someone please help to understand the problem?有人可以帮助理解这个问题吗? Thanks in advance!提前致谢!

In my case, I encountered the problem in a docker image based on eclipse-temurin:17-jdk-alpine running a webapp that generates excel files using apache poi.就我而言,我在基于eclipse-temurin:17-jdk-alpine镜像中遇到了问题,该镜像运行了一个使用 apache poi 生成 excel 文件的 webapp。 After adding the packages fontconfig and ttf-dejavu as follows (it seems that freetype is a dependency of fontconfig and therefore does not have to be installed explicitly):如下添加包fontconfigttf-dejavu后(似乎freetypefontconfig的依赖项,因此不必显式安装):

RUN apk add --no-cache fontconfig ttf-dejavu

not only the class FontText.java given here:不仅是这里给出的类FontText.java

https://github.com/AdoptOpenJDK/openjdk-docker/issues/529#issuecomment-811687786 https://github.com/AdoptOpenJDK/openjdk-docker/issues/529#issuecomment-811687786

ran successfully, but also it was possible to generate excel files, which before resulted in the exception given in the question and in this exception:成功运行,但也可以生成 excel 文件,这之前导致问题和此异常中给出的异常:

...
Caused by: java.lang.UnsatisfiedLinkError: /opt/java/openjdk/lib/libfontmanager.so: Error loading shared library libfreetype.so.6: No such file or directory (needed by /opt/java/openjdk/lib/libfontmanager.so)
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NoClassDefFoundError:无法初始化类 sun.awt.X11FontManager - NoClassDefFoundError: Could not initialize class sun.awt.X11FontManager 无法在高山Linux上使用openjdk 8初始化类sun.awt.X11FontManager - Could not initialize class sun.awt.X11FontManager using openjdk 8 on alpine linux sun.awt.X11FontManager: java.lang.reflect.InvocationTargetException (Arch Linux) - sun.awt.X11FontManager: java.lang.reflect.InvocationTargetException (Arch Linux) 无法在 Solaris 上初始化类 sun.awt.X11GraphicsEnvironment - Could not initialize class sun.awt.X11GraphicsEnvironment on Solaris NoClassDefFoundError:无法初始化类sun.awt.X11GraphicsEnvironment - NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment 无法运行IntelliJ-NoClassDefFoundError:无法初始化类sun.awt.X11GraphicsEnvironment - Cannot run IntelliJ - NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment MuleESB-无法初始化类sun.awt.SunToolkit - MuleESB - Could not initialize class sun.awt.SunToolkit 无法初始化类java.awt.Rectangle - Could not initialize class java.awt.Rectangle Java二进制兼容性问题:sun.font.FontManager类成为接口 - Java binary compatibility issue: sun.font.FontManager class became interface java.lang.NoClassDefFoundError:sun / awt / X11GraphicsEnvironment在Linux上运行基于applet的app时面临的问题 - java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment issuses faced while running our applet based app on linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM