yuzutech / kroki

Creates diagrams from textual descriptions!
https://kroki.io
MIT License
2.89k stars 216 forks source link

[plantuml] Could not initialize class net.sourceforge.plantuml.ugraphic.UFont #907

Closed wasphin closed 3 years ago

wasphin commented 3 years ago

According to the FAQ here, fontconfig is required.

If you have the error message java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.plantuml.ugraphic.UFont, it probably means that there are no fonts installed on your server.

You can solve it by adding fontconfig on your system

wasphin commented 3 years ago

Fail to reproduce in another OS with the very same image(0.14.0).

Any ideas? Thanks.

ggrossetie commented 3 years ago

Could you please provide detailed information about your host OS? Also, could you please provide the exact command you are running and the complete stacktrace?

Thanks.

wasphin commented 3 years ago

The two OSes are almost the same, both are RHEL 7 like distributions with the same version(7.6), except that one with podman installed and another with docker installed.

With the same yuzutech/kroki image(tag: 0.14.0, image id: a266eb9ab961), plantuml works fine when use docker to run at machine A, but not working when use podman at machine B.

Here is the OS info:

$ cat /etc/os-release 
NAME="Scientific Linux"
VERSION="7.6 (Nitrogen)"
ID="scientific"
ID_LIKE="rhel centos fedora"
VERSION_ID="7.6"
PRETTY_NAME="Scientific Linux 7.6 (Nitrogen)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:scientificlinux:scientificlinux:7.6:GA"
HOME_URL="http://www.scientificlinux.org//"
BUG_REPORT_URL="mailto:scientific-linux-devel@listserv.fnal.gov"

REDHAT_BUGZILLA_PRODUCT="Scientific Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.6
REDHAT_SUPPORT_PRODUCT="Scientific Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.6"

The plantuml script:

Alice -> Bob

Using online service provided by https://kroki.io

The backtrace:

java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.plantuml.ugraphic.UFont
    at net.sourceforge.plantuml.graphic.GraphicStrings.sansSerif12(GraphicStrings.java:119)
    at net.sourceforge.plantuml.graphic.GraphicStrings.createBlackOnWhite(GraphicStrings.java:114)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:190)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:162)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:155)
    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:157)
    at io.kroki.server.service.Plantuml.convert(Plantuml.java:274)
    at io.kroki.server.service.Plantuml.lambda(Plantuml.java:235)
    at io.vertx.core.impl.ContextImpl.lambda-bash(ContextImpl.java:160)
    at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)
    at io.vertx.core.impl.ContextImpl.lambda(ContextImpl.java:158)
    at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.run(Unknown Source)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Unknown Source)

And here is the log when access http://192.168.6.201:8080/plantuml/svg/eNpzzMlMTlXQtVNwyk8CABgjA50=

{
   "timestamp":"1631967837960",
   "level":"INFO",
   "thread":"vert.x-eventloop-thread-1",
   "mdc":{
      "path":"/plantuml/svg/eNpzzMlMTlXQtVNwyk8CABgjA50=",
      "method":"GET",
      "service_name":"plantuml",
      "action":"request_received",
      "bytes_read":"0",
      "user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
   },
   "logger":"io.kroki.server.service.DiagramHandler",
   "message":"Request received GET /plantuml/svg/eNpzzMlMTlXQtVNwyk8CABgjA50=",
   "context":"default"
}
{
   "timestamp":"1631967837988",
   "level":"INFO",
   "thread":"vert.x-eventloop-thread-1",
   "mdc":{
      "path":"/plantuml/svg/eNpzzMlMTlXQtVNwyk8CABgjA50=",
      "took":"27",
      "method":"GET",
      "service_name":"plantuml",
      "action":"convert",
      "file_format":"svg",
      "user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
   },
   "logger":"io.kroki.server.service.DiagramHandler",
   "message":"Convert took 27ms",
   "context":"default"
}
{
   "timestamp":"1631967837989",
   "level":"INFO",
   "thread":"vert.x-eventloop-thread-1",
   "logger":"io.vertx.ext.web.RoutingContext",
   "message":"RoutingContext failure (500)",
   "context":"default",
   "exception":"java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.plantuml.ugraphic.UFont\n\tat net.sourceforge.plantuml.graphic.GraphicStrings.sansSerif12(GraphicStrings.java:119)\n\tat net.sourceforge.plantuml.graphic.GraphicStrings.createBlackOnWhite(GraphicStrings.java:114)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:190)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:162)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:155)\n\tat net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:157)\n\tat io.kroki.server.service.Plantuml.convert(Plantuml.java:274)\n\tat io.kroki.server.service.Plantuml.lambda$convert$5(Plantuml.java:235)\n\tat io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:160)\n\tat io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)\n\tat io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:158)\n\tat io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n"
}
{
   "timestamp":"1631967837989",
   "level":"ERROR",
   "thread":"vert.x-eventloop-thread-1",
   "mdc":{
      "error_message":"OK",
      "path":"/plantuml/svg/eNpzzMlMTlXQtVNwyk8CABgjA50=",
      "method":"GET",
      "action":"error",
      "error_code":"500",
      "failure_class_name":"java.lang.NoClassDefFoundError",
      "user_agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36"
   },
   "logger":"io.kroki.server.error.ErrorHandler",
   "message":"An error occurred",
   "context":"default",
   "exception":"java.lang.NoClassDefFoundError: Could not initialize class net.sourceforge.plantuml.ugraphic.UFont\n\tat net.sourceforge.plantuml.graphic.GraphicStrings.sansSerif12(GraphicStrings.java:119)\n\tat net.sourceforge.plantuml.graphic.GraphicStrings.createBlackOnWhite(GraphicStrings.java:114)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:190)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramError(UmlDiagram.java:162)\n\tat net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:155)\n\tat net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:157)\n\tat io.kroki.server.service.Plantuml.convert(Plantuml.java:274)\n\tat io.kroki.server.service.Plantuml.lambda$convert$5(Plantuml.java:235)\n\tat io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:160)\n\tat io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)\n\tat io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:158)\n\tat io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\tat io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)\n\tat java.base/java.lang.Thread.run(Unknown Source)\n"
}
ggrossetie commented 3 years ago

Thanks for your detailed response.

The two OSes are almost the same, both are RHEL 7 like distributions with the same version(7.6), except that one with podman installed and another with docker installed. With the same yuzutech/kroki image(tag: 0.14.0, image id: a266eb9ab961), plantuml works fine when use docker to run at machine A, but not working when use podman at machine B.

So it might be related to podman. Could you please run the following command podman version?

Also, it would be interesting to (install and) run podman on machine A. If it does not work then it's definitely an issue with using Kroki with podman.

ggrossetie commented 3 years ago

I cannot reproduce this issue using GitHub Actions with:

https://github.com/yuzutech/kroki/runs/3645468361

wasphin commented 3 years ago

Have installed a new OS, and fail to reproduce it with podman(1.6.4-29), there's another difference between the new OS and the old one. In the old one, I changed the container storage directory, but didn't fix the SELINUX label! The docker one did fix it.

After fixing the SELINUX of the customized storage directory, plantuml works. Comparing to others, plantuml may need to access the file system to store some temporary files.

Thanks @Mogztter, it really a great work.