Re: Exception when moving from windows to linux
Andreas Reichel <[email protected]>
| Newsgroups | gmane.comp.jakarta.poi.user |
|---|---|
| Message-ID | <2849c5d5121fa249443d12014cc1942de451ca3a.camel@manticore-projects.com> |
Dear Matthias, please try to install the X Virtual Frame Buffer (XVFB) and start that in the background, before starting the Java VM. As far as I know, the Java VM needs a Graphic Device for all the AWT based operations, inclduing Fonts. Best regards Andreas On Wed, 2020-02-19 at 08:40 +0100, Matthias Pfeifer wrote: > Hi there, > > I am using apache poi 4.1.0 and i have some code that should create a > Workbook, create a sheet, put some data in it and store it into file > system. My code runs fine on my windows box but throws exception when > moving to linux (please no jokes about linux box refusing code due to bad > smell, i had some of those already ;-) ). > > I am running into this exception when I am calling autoSizeColumn(...) on a > XSSFSheet (in a XSSFWorkbook)... > > Here's my stacktrace: > > java.lang.InternalError: java.lang.reflect.InvocationTargetException > at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86) > ~[?:?] > at java.security.AccessController.doPrivileged(Native Method) ~[?:?] > at > sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74) ~[?:?] > at java.awt.Font.getFont2D(Font.java:497) ~[?:?] > at java.awt.Font.canDisplayUpTo(Font.java:2246) ~[?:?] > at java.awt.font.TextLayout.singleFont(TextLayout.java:469) ~[?:?] > at java.awt.font.TextLayout.<init>(TextLayout.java:530) ~[?:?] > at > org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:273) > ~[poi-4.1.0.jar:4.1.0] > at > org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:248) > ~[poi-4.1.0.jar:4.1.0] > at > org.apache.poi.ss.util.SheetUtil.getColumnWidth(SheetUtil.java:233) > ~[poi-4.1.0.jar:4.1.0] > at > org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:549) > ~[poi-ooxml-4.1.0.jar:4.1.0] > at > org.apache.poi.xssf.usermodel.XSSFSheet.autoSizeColumn(XSSFSheet.java:531) > ~[poi-ooxml-4.1.0.jar:4.1.0] > at my.package.rest.api.exportTable(ExportTable.java:181) > ~[classes/:?] > <SNIP> > > Caused by: java.lang.reflect.InvocationTargetException > at > jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) ~[?:?] > at > jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > ~[?:?] > at > jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > ~[?:?] > at java.lang.reflect.Constructor.newInstance(Constructor.java:490) > ~[?:?] > at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84) > ~[?:?] > ... 63 more > > Caused by: java.lang.NullPointerException > at > sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262) ~[?:?] > at > sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225) > ~[?:?] > at sun.awt.FontConfiguration.init(FontConfiguration.java:107) ~[?:?] > at > sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719) > ~[?:?] > at sun.font.SunFontManager$2.run(SunFontManager.java:367) ~[?:?] > at java.security.AccessController.doPrivileged(Native Method) ~[?:?] > at sun.font.SunFontManager.<init>(SunFontManager.java:312) ~[?:?] > at sun.awt.FcFontManager.<init>(FcFontManager.java:35) ~[?:?] > at sun.awt.X11FontManager.<init>(X11FontManager.java:56) ~[?:?] > at > jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) ~[?:?] > at > jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > ~[?:?] > at > jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > ~[?:?] > at java.lang.reflect.Constructor.newInstance(Constructor.java:490) > ~[?:?] > at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84) > ~[?:?] > ... 63 more > > > I got the impression that the issue might deal with font availability on > linux. The host system has no x11 installed for example. > > How would I be able to have my code running on the linux box? Is the choice > of Workbook important? Would it help to use a HSSFWorkbook instead? > > > > Thanks in advance > > > Matthias.