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

The dreaded NullPointerException in sun.awt.FontConfiguration #25

Closed
elbosso opened this issue Aug 30, 2020 · 5 comments
Closed

The dreaded NullPointerException in sun.awt.FontConfiguration #25

elbosso opened this issue Aug 30, 2020 · 5 comments

Comments

@elbosso
Copy link

elbosso commented Aug 30, 2020

Docker images based on Alpine seem to have this problem often:

When i switched to bellsoft/liberica-openjdk-debian, the problem was gone. However I tried the workarounds mentioned in the links above and none of them worked. So I think there must be one slight difference between the alpine-based and the debian-based image that triggers certain fringe cases. I include the stacktrace below. It happens for example when one builds and runs project https://github.com/elbosso/generator-microservices with bellsoft/liberica-openjdk-alpine and then tries to execute

curl -X GET "http://<host>:<port>/nixieNumberImg" -H  "accept: application/json"

against it.

Stacktrace:

java.lang.InternalError: java.lang.reflect.InvocationTargetException
pi_microgenerator-q    |        at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
pi_microgenerator-q    |        at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
pi_microgenerator-q    |        at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
pi_microgenerator-q    |        at java.desktop/sun.font.SunFontManager.getInstance(SunFontManager.java:249)
pi_microgenerator-q    |        at java.desktop/sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:261)
pi_microgenerator-q    |        at java.desktop/sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1243)
pi_microgenerator-q    |        at java.desktop/javax.swing.JComponent.getFontMetrics(JComponent.java:1646)
pi_microgenerator-q    |        at java.desktop/javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:246)
pi_microgenerator-q    |        at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1680)
pi_microgenerator-q    |        at java.desktop/java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:1109)
pi_microgenerator-q    |        at java.desktop/java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:904)
pi_microgenerator-q    |        at java.desktop/java.awt.GridBagLayout.preferredLayoutSize(GridBagLayout.java:724)
pi_microgenerator-q    |        at java.desktop/java.awt.Container.preferredSize(Container.java:1823)
pi_microgenerator-q    |        at java.desktop/java.awt.Container.getPreferredSize(Container.java:1807)
pi_microgenerator-q    |        at java.desktop/javax.swing.JComponent.getPreferredSize(JComponent.java:1682)
pi_microgenerator-q    |        at de.elbosso.util.generator.generalpurpose.NixieNumberImageSequence.next(NixieNumberImageSequence.java:98)
pi_microgenerator-q    |        at de.elbosso.microgenerator.handlers.java.awt.image.bufferedimage.NixieNumberImageSequenceHandler$1.write(NixieNumberImageSequenceHandler.java:69)
pi_microgenerator-q    |        at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:37)
pi_microgenerator-q    |        at org.jboss.resteasy.plugins.providers.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:20)
pi_microgenerator-q    |        at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:193)
pi_microgenerator-q    |        at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:64)
pi_microgenerator-q    |        at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:155)
pi_microgenerator-q    |        at org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$2(ServerResponseWriter.java:156)
pi_microgenerator-q    |        at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:404)
pi_microgenerator-q    |        at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:232)
pi_microgenerator-q    |        at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:97)
pi_microgenerator-q    |        at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:70)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:578)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:508)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
pi_microgenerator-q    |        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
pi_microgenerator-q    |        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
pi_microgenerator-q    |        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
pi_microgenerator-q    |        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:109)
pi_microgenerator-q    |        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatchRequestContext(VertxRequestHandler.java:84)
pi_microgenerator-q    |        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.lambda$handle$0(VertxRequestHandler.java:71)
pi_microgenerator-q    |        at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:316)
pi_microgenerator-q    |        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
pi_microgenerator-q    |        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
pi_microgenerator-q    |        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
pi_microgenerator-q    |        at java.base/java.lang.Thread.run(Thread.java:832)
pi_microgenerator-q    | Caused by: java.lang.reflect.InvocationTargetException
pi_microgenerator-q    |        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
pi_microgenerator-q    |        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
pi_microgenerator-q    |        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
pi_microgenerator-q    |        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
pi_microgenerator-q    |        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
pi_microgenerator-q    |        at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
pi_microgenerator-q    |        ... 42 more
pi_microgenerator-q    | Caused by: java.lang.NullPointerException
pi_microgenerator-q    |        at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
pi_microgenerator-q    |        at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
pi_microgenerator-q    |        at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
pi_microgenerator-q    |        at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
pi_microgenerator-q    |        at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:374)
pi_microgenerator-q    |        at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
pi_microgenerator-q    |        at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:319)
pi_microgenerator-q    |        at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
pi_microgenerator-q    |        at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
pi_microgenerator-q    |        ... 48 more
elbosso pushed a commit to elbosso/generator-microservices that referenced this issue Aug 30, 2020
elbosso pushed a commit to elbosso/generator-microservices-q that referenced this issue Aug 30, 2020
@den1ska
Copy link
Collaborator

den1ska commented Aug 31, 2020

Hi,
liberica-openjdk-alpine is a glibc-based image, therefore, every time you're adding smth using apk you have to run /usr/glibc/sbin/ldconfig manually.

Please try adding the following lines into your Dockerfile:

RUN apk add --no-cache fontconfig ttf-dejavu && /usr/glibc/sbin/ldconfig

@den1ska
Copy link
Collaborator

den1ska commented Sep 23, 2020

When adding native Alpine Linux packages using apk it's important to keep in mind that Liberica JDK within this image is glibc-based. Thus it's required to run /usr/glibc/sbin/ldconfig manually after adding any system packages. This includes adding apk packages in Dockerfile directly. For example:

RUN apk add --no-cache fontconfig ttf-dejavu && /usr/glibc/sbin/ldconfig

@den1ska den1ska closed this as completed Sep 23, 2020
@kpy3no
Copy link

kpy3no commented Nov 11, 2021

after add RUN apk add --no-cache fontconfig ttf-dejavu && /usr/glibc/sbin/ldconfig.
there is error:

`[error occurred during error reporting ((null)), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing fatal error message), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing type of error), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing exception/signal name), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing current thread and pid), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing error message), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing Java version string), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing problematic frame), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing core file information), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing bug submit message), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing summary), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing VM option summary), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing summary machine and OS info), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing date and time), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing thread), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing current thread), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing current compile task), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing stack bounds), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing native stack), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing Java stack), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing target Java thread stack), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing siginfo), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (CDS archive access warning), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing register info), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing registers, top of stack, instructions near pc), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (inspecting top of stack), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing code blob if possible), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing VM operation), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing process), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing user info), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[error occurred during error reporting (printing all threads), id 0xb, SIGSEGV (0xb) at pc=0x00007f162879acf4]

[Too many errors, abort]
[Too many errors, abort]

`

my dockerfile
FROM bellsoft/liberica-openjre-alpine:11.0.13-8
COPY ./target/test-1.0-SNAPSHOT.jar test-1.0-SNAPSHOT.jar
RUN apk add fontconfig ttf-dejavu && /usr/glibc/sbin/ldconfig
ENTRYPOINT ["java","-jar","test-1.0-SNAPSHOT.jar"]

Work only after change base image:

FROM bellsoft/liberica-openjdk-debian:11.0.13-8
COPY ./target/test-1.0-SNAPSHOT.jar test-1.0-SNAPSHOT.jar
ENTRYPOINT ["java","-jar","test-1.0-SNAPSHOT.jar"]

@varpa89
Copy link

varpa89 commented May 3, 2022

@kpy3no hi! have you found how to fix it with alpine image?

@varpa89
Copy link

varpa89 commented May 3, 2022

@den1ska could you please help? what is the reason of
[Too many errors, abort]
?

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

No branches or pull requests

4 participants