Bug 63230 - ClassCastException on OpenJDK 11
Summary: ClassCastException on OpenJDK 11
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: POI Overall (show other bugs)
Version: 4.0.x-dev
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-04 15:56 UTC by M. Noack
Modified: 2019-03-11 20:35 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description M. Noack 2019-03-04 15:56:12 UTC
Hello,

i running a java application on Linux maschines with openJdk 11. When creating a worksheet like 

 SXSSFWorkbook workbook = new SXSSFWorkbook(-1);
 SXSSFSheet sheet = workbook.createSheet("testsheet");

i run into follwoing error:

 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') at sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1086) ~[?:?]
at sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:965) ~[?:?]
at sun.font.SunFontManager.findOtherDeferredFont(SunFontManager.java:903) ~[?:?]
at sun.font.SunFontManager.findDeferredFont(SunFontManager.java:919) ~[?:?]
at sun.font.SunFontManager.findFont2D(SunFontManager.java:2120) ~[?:?]
at java.awt.Font.getFont2D(Font.java:506) ~[?:?] 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.0.1.jar!/:4.0.1]
at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117) ~[poi-ooxml-4.0.1.jar!/:4.0.1]
at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82) ~[poi-ooxml-4.0.1.jar!/:4.0.1]
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:664) ~[poi-ooxml-4.0.1.jar!/:4.0.1]
at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:685) ~[poi-ooxml-4.0.1.jar!/:4.0.1]

Everthing works fine with openJdk10 or if i run it under windows. 
Hope you can help?
Comment 1 PJ Fanning 2019-03-04 16:44:04 UTC
Can you try with the latest POI release - 4.0.1?
Comment 2 M. Noack 2019-03-05 07:18:07 UTC
I did already. Sorry I did not mentioned it. Same problem.
Comment 3 Dominik Stadler 2019-03-10 09:36:25 UTC
We cannot reproduce this locally and also not in CI, we run our large set of unit-tests against various versions of the JDK, so this seems to be something that is caused by your local setup of font-related packages.

What exact operating system are you running? 

Can you also attach a list of font-related packages that are installed? I.e. something like the output of "dpkg --list | grep -i font"?
Comment 4 M. Noack 2019-03-11 12:10:23 UTC
We are running Suse Linux Enterprise Server 11.4. There are no font-related packages installed.
Comment 5 Dominik Stadler 2019-03-11 20:23:59 UTC
There is a related question at https://stackoverflow.com/questions/54554625/openjdk-11-java-lang-classcastexception-class-sun-font-compositefont-cannot-be, but no solution or hint.

It seems OpenJDK does not include some font-related stuff any more and your operating system is currently not providing any by itself. Maybe you can try to install some font-related packages to see if that solves the problem.

See also the release notes at https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#JDK-8191522 

Overall I don't think we can do much in Apache POI itself as the problem is a combination of installed os-packages and OpenJDK 11.
Comment 6 Dominik Stadler 2019-03-11 20:35:27 UTC
FYI, installing OpenJKD 11 on a bare Ubuntu system wants to install "fontconfig" and "fonts-dejavu-core", maybe there are similar packages on Suse.