Pentaho / POI抛出InvocationTargetException

问题描述 投票:0回答:1

我正在尝试将我的所有Java应用程序升级到openJDK11(来自Oracle 8)。我注意到我的报告服务器中有一个使用Pentaho的问题。

似乎Excel自动调整大小功能需要openJDK11中的libfontconfig.so,

但是我可以在/usr/lib64/libfontconfig.so找到该模块。 enter image description here

有办法解决这个问题吗?

    2019/04/18 19:22:38 - GetReportJSon.0 - Finished reading query, closing connection.
    2019/04/18 19:22:38 - GetReportJSon.0 - Finished processing (I=1, O=0, R=0, W=2, U=0, E=0)
    java.lang.InternalError: java.lang.reflect.InvocationTargetException
                    at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
                    at java.base/java.security.AccessController.doPrivileged(Native Method)
                    at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
                    at java.desktop/java.awt.Font.getFont2D(Font.java:497)
                    at java.desktop/java.awt.Font.canDisplayUpTo(Font.java:2246)
                    at java.desktop/java.awt.font.TextLayout.singleFont(TextLayout.java:469)
                    at java.desktop/java.awt.font.TextLayout.<init>(TextLayout.java:530)
                    at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:273)
                    at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:248)
                    at org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:233)
                    at org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:551)
                    at org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:533)
                    at org.pentaho.di.trans.steps.excelwriter.ExcelWriterStep.closeOutputFile(ExcelWriterStep.java:244)
                    at org.pentaho.di.trans.steps.excelwriter.ExcelWriterStep.processRow(ExcelWriterStep.java:209)
                    at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
                    at java.base/java.lang.Thread.run(Thread.java:834)
    Caused by: java.lang.reflect.InvocationTargetException
                    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
                    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
                    at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
                    ... 15 more
    Caused by: java.lang.NullPointerException
                    at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
                    at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
                    at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
                    at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
                    at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:367)
                    at java.base/java.security.AccessController.doPrivileged(Native Method)
                    at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:312)
                    at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
                    at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
                    ... 20 more
    2019/04/18 19:22:40 - WriteReportAuthor.0 - ERROR (version 7.0.0.1-7, build 1 from 2016-12-07 21.19.28 by buildguy) : Unexpected error
    2019/04/18 19:22:40 - WriteReportAuthor.0 - ERROR (version 7.0.0.1-7, build 1 from 2016-12-07 21.19.28 by buildguy) : java.lang.InternalError: java.lang.reflect.InvocationTargetException

更新:

放'-Dsun.java2d.debugfonts = true'之后我得到了这个日志:

Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.7.2.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.7.2.bfc
Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.7.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.7.bfc
Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.RedHat.bfc
Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.7.2.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.7.2.bfc
Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.7.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.7.bfc
Looking for text fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.properties
Looking for binary fontconfig file : /opt/jdk11/jdk-11.0.1/lib/fontconfig.bfc
Did not find a fontconfig file.
pentaho java-11 fontconfig
1个回答
0
投票

解决2件事(使用docker实现):

  1. 添加配置变量: 这需要让JDK知道libfontconfig.so的位置在哪里

ENV LD_LIBRARY_PATH =“$ {LD_LIBRARY_PATH}:/ usr / lib /:/ usr / lib64 /”

  1. 将默认文件添加到JDK / lib文件夹: 这是必需的,因为默认情况下openjdk没有它。以下文件来自Oracle JDK8
ADD ./src/main/resources/fontconfig.bfc /opt/jdk11/jdk-11.0.1/lib/fontconfig.bfc

ADD ./src/main/resources/fontconfig.properties.src /opt/jdk11/jdk-11.0.1/lib/fontconfig.properties.src

ADD ./src/main/resources/fonts /opt/jdk11/jdk-11.0.1/lib/fonts

更新:上面的解决方案有效,但有时加载redhat linux后,似乎无法找到字体并给出"java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')"。 10-30分钟后,问题就消失了。

解决方案:

  1. 添加额外的TTF文件(对我而言,它是calibri.ttf)并复制到/ usr / share / fonts / TTF
  2. 执行此命令:fc-cache -fv这是为了确保fontconfig立即加载字体。
ADD ./src/main/resources/fonts/*.ttf /usr/share/fonts/TTF/
RUN fc-cache -fv
© www.soinside.com 2019 - 2024. All rights reserved.