AWS ElasticBeanstalk 实例上的 Apache Batik 库出现问题

发布于 2024-12-13 02:59:34 字数 4255 浏览 0 评论 0原文

我正在使用 AWS Elasti Beanstalk 为我的一个应用程序提供支持。在此,我需要将 svg 文档导出为 png、jpg、pdf 等。为此,我使用 Apache Batik 库。这在我的本地开发工作站上提供了出色的输出,但一旦我将其部署到 EBS 上,我就开始收到错误,所有错误都与字体有关。

错误堆栈跟踪是 -

Caused by: java.lang.Error: Probable fatal error:No fonts found. 
    at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088) 
    at sun.font.FontManager.initialiseDeferredFont(FontManager.java:960) 
    at sun.font.FontManager.findOtherDeferredFont(FontManager.java:899) 
    at sun.font.FontManager.findDeferredFont(FontManager.java:916) 
    ...
    at sun.font.FontManager.findFont2D(FontManager.java:1904) 
    at sun.font.FontManager.initialiseDeferredFonts(FontManager.java:792) 
    at sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:468)
    at sun.awt.X11GraphicsEnvironment.loadFonts(X11GraphicsEnvironment.java:925) 
    at sun.java2d.SunGraphicsEnvironment.loadFontFiles(SunGraphicsEnvironment.java:498) 
    at sun.java2d.SunGraphicsEnvironment.getInstalledFontFamilyNames(SunGraphicsEnvironment.java:721) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:746) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:773) 
    at sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:99) 
    at org.apache.batik.gvt.font.FontFamilyResolver.(FontFamilyResolver.java:74) 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(SVGTextElementBridge.java:1529) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(SVGTextElementBridge.java:1610) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(SVGTextElementBridge.java:902) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(SVGTextElementBridge.java:856) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:636)
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:292) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171) 
    at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)

所以我尝试将字体安装为 ​​另一个 stackoverflow答案表明。 但这给了我一个新的错误堆栈跟踪 -

Caused by: java.lang.NoClassDefFoundError: 
Could not initialize class org.apache.batik.gvt.font.FontFamilyResolver 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.build(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 

我不明白为什么会发生这种情况。然后我在调用蜡染的转码器之前设置了 System.setProperty("java.awt.headless", "true"); 。但这也会产生上述错误消息。我已经没有选择了。

我错过了什么吗?我可以做些什么来添加更多背景信息吗?感谢您的帮助。

I am using AWS Elasti Beanstalk to power one of my apps. In this I need to export a svg document to png,jpg, pdf etc. For this I use Apache Batik library. This provides excellent output on my local dev workstation but as soon as I deploy it on the EBS I start getting errors, all related to fonts.

The error stacktrace was -

Caused by: java.lang.Error: Probable fatal error:No fonts found. 
    at sun.font.FontManager.getDefaultPhysicalFont(FontManager.java:1088) 
    at sun.font.FontManager.initialiseDeferredFont(FontManager.java:960) 
    at sun.font.FontManager.findOtherDeferredFont(FontManager.java:899) 
    at sun.font.FontManager.findDeferredFont(FontManager.java:916) 
    ...
    at sun.font.FontManager.findFont2D(FontManager.java:1904) 
    at sun.font.FontManager.initialiseDeferredFonts(FontManager.java:792) 
    at sun.java2d.SunGraphicsEnvironment.loadFonts(SunGraphicsEnvironment.java:468)
    at sun.awt.X11GraphicsEnvironment.loadFonts(X11GraphicsEnvironment.java:925) 
    at sun.java2d.SunGraphicsEnvironment.loadFontFiles(SunGraphicsEnvironment.java:498) 
    at sun.java2d.SunGraphicsEnvironment.getInstalledFontFamilyNames(SunGraphicsEnvironment.java:721) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:746) 
    at sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:773) 
    at sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:99) 
    at org.apache.batik.gvt.font.FontFamilyResolver.(FontFamilyResolver.java:74) 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(SVGTextElementBridge.java:1529) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(SVGTextElementBridge.java:1610) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(SVGTextElementBridge.java:902) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(SVGTextElementBridge.java:856) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(SVGTextElementBridge.java:636)
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(SVGTextElementBridge.java:292) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(GVTBuilder.java:224) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(GVTBuilder.java:171) 
    at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:82) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:208) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:92) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)

So I tried installing fonts as one other stackoverflow answer suggests. But this gave me a new error stacktrace -

Caused by: java.lang.NoClassDefFoundError: 
Could not initialize class org.apache.batik.gvt.font.FontFamilyResolver 
    at org.apache.batik.bridge.SVGTextElementBridge.getFontList(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.getAttributeMap(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.fillAttributedStringBuffer(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildAttributedString(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.computeLaidoutText(Unknown Source) 
    at org.apache.batik.bridge.SVGTextElementBridge.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildGraphicsNode(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.buildComposite(Unknown Source) 
    at org.apache.batik.bridge.GVTBuilder.build(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.image.ImageTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source) 
    at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source) 

I dont understand why is this happening. Then I set System.setProperty("java.awt.headless", "true"); just before I make a call to batik's transcoder. But this also generate the above error message. I am running out of options.

Am I missing something? Can I do anything to add more context to this? Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

檐上三寸雪 2024-12-20 02:59:34

我将以下依赖项添加到我的 maven pom.xml 文件中,它似乎使该类可供使用:

<dependency>
    <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>batik-gvt</artifactId>
    <version>1.7</version>
</dependency>

但是请注意,它映射到的字体并不总是具有与 MS 核心字体相同的尺寸( arial、times new roman 等),因此可能看起来有点块状或与它们要替换的不同。

I added the following dependency to my maven pom.xml file, and it seems to have made the class available for use:

<dependency>
    <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>batik-gvt</artifactId>
    <version>1.7</version>
</dependency>

Note, however, that the fonts that it maps to don't always have the same dimensions as the MS core fonts (arial, times new roman, etc.) so can look kind of blocky or different than the ones they're replacing.

明月夜 2024-12-20 02:59:34

我最终通过安装Sun JDK & 解决了这个问题。用它来驱动我的 tomcat 服务器。

I finally resolved this problem by installing Sun JDK & using it to power my tomcat server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文