Bug 62966

Summary: init presetShapeDefinitions.xml fail under IBM jdk
Product: POI Reporter: scmodabc <smdlzc>
Component: SL CommonAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.0.x-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 62994    

Description scmodabc 2018-11-30 02:16:54 UTC
i want to read the ppt/pptx and draw into images
here is some test:
{
BufferedImage img = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
try {
	SlideShow ss = SlideShowFactory.create(Init.class.getClassLoader().getResourceAsStream("ppt.ppt"));
	List<? extends Slide> slide = ss.getSlides();
	Graphics2D graphics = img.createGraphics();
	slide.get(0).draw(graphics);
} catch (Exception e) {
	e.printStackTrace();
}
try {
	SlideShow ss = SlideShowFactory.create(Init.class.getClassLoader().getResourceAsStream("ppt.pptx"));
	List<? extends Slide> slide = ss.getSlides();
	Graphics2D graphics = img.createGraphics();
	slide.get(0).draw(graphics);
} catch (Exception e) {
	e.printStackTrace();
}
System.out.println("fin");
}
when run this code under oracle or openjdk it's all ok.
but when run in websphere, it always brings a RuntimeException like this:
java.lang.RuntimeException: java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a 4 event
        at org.apache.poi.sl.draw.geom.PresetGeometries.getInstance(PresetGeometries.java:115)
        at org.apache.poi.hslf.usermodel.HSLFSimpleShape.getGeometry(HSLFSimpleShape.java:341)
        at org.apache.poi.sl.draw.DrawSimpleShape.computeOutlines(DrawSimpleShape.java:390)
        at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:75)
        at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:67)
        at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:39)
        at org.apache.poi.hslf.usermodel.HSLFSlide.draw(HSLFSlide.java:467)
        at ppt.Init.main(Init.java:19)
Caused by: java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a 4 event
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:455)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:433)
        at org.apache.poi.sl.draw.geom.PresetGeometries.init(PresetGeometries.java:75)
        at org.apache.poi.sl.draw.geom.PresetGeometries.getInstance(PresetGeometries.java:110)
        ... 7 more
java.lang.RuntimeException: java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a 4 event
        at org.apache.poi.sl.draw.geom.PresetGeometries.getInstance(PresetGeometries.java:115)
        at org.apache.poi.xslf.usermodel.XSLFSimpleShape.getGeometry(XSLFSimpleShape.java:686)
        at org.apache.poi.sl.draw.DrawSimpleShape.computeOutlines(DrawSimpleShape.java:390)
        at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:75)
        at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:67)
        at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:39)
        at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:301)
        at ppt.Init.main(Init.java:27)
Caused by: java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a 4 event
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:455)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:433)
        at org.apache.poi.sl.draw.geom.PresetGeometries.init(PresetGeometries.java:75)
        at org.apache.poi.sl.draw.geom.PresetGeometries.getInstance(PresetGeometries.java:110)
        ... 7 more
fin


the ibm jdk version I've test is
java version "1.8.0"
Java(TM) SE Runtime Environment (build pxa6480sr2fp10ifix-20160223_01(SR2 FP10+IV81318+IV81645+IV81741+IV81716))
IBM J9 VM (build 2.8, JRE 1.8.0 Linux amd64-64 Compressed References 20160210_289934 (JIT enabled, AOT enabled)
J9VM - R28_Java8_SR2_20160210_1617_B289934
JIT  - tr.r14.java_20151209_107110.04
GC   - R28_Java8_SR2_20160210_1617_B289934_CMPRSS
J9CL - 20160210_289934)
JCL - 20151231_01 based on Oracle jdk8u71-b15

And

java version "1.7.0"
Java(TM) SE Runtime Environment (build pxa6470sr4fp1ifix-20130423_02(SR4 FP1+IV38579+IV38399+IV40208))
IBM J9 VM (build 2.6, JRE 1.7.0 Linux amd64-64 Compressed References 20130421_145945 (JIT enabled, AOT enabled)
J9VM - R26_Java726_SR4_FP1_2_20130421_2353_B145945
JIT  - r11.b03_20130131_32403ifx4
GC   - R26_Java726_SR4_FP1_2_20130421_2353_B145945_CMPRSS
J9CL - 20130422_145945)
JCL - 20130225_01 based on Oracle 7u13-b08

Is this a poi bug when use xmlreader to initialize presetShapeDefinitions.xml
or a ibm jdk xmlreader bug processing xml element event
Comment 1 PJ Fanning 2018-11-30 08:36:43 UTC
If you can load the ppt using one JDK and not another, then I'd suggest that the issue is likely to be in the second JDK.
Could you try upgrading your JDK and if IBM JDK continues to be an issue, could you try up to date versions of OpenJDK or Oracle JDK?
Comment 2 scmodabc 2018-12-03 05:33:48 UTC
(In reply to PJ Fanning from comment #1)
> If you can load the ppt using one JDK and not another, then I'd suggest that
> the issue is likely to be in the second JDK.
> Could you try upgrading your JDK and if IBM JDK continues to be an issue,
> could you try up to date versions of OpenJDK or Oracle JDK?

I have tried to install up to date ibm jdk,and encountered a RuntimeException as before.
ibm jdk version:
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 8.0.5.26 - pxa6480sr5fp26-20181115_03(SR5 FP26))
IBM J9 VM (build 2.9, JRE 1.8.0 Linux amd64-64-Bit Compressed References 20181106_401576 (JIT enabled, AOT enabled)
OpenJ9   - fde1d6f
OMR      - d8c3617
IBM      - 5c4a9f0)
JCL - 20181022_01 based on Oracle jdk8u191-b26
while newest OpenJDK and OracleJDK works fine
perhaps I have to configure websphere to use openjdk or oraclejdk.
Thank you
Comment 3 PJ Fanning 2018-12-03 08:07:47 UTC
Maybe you should report this JAXB issue to IBM.
Comment 4 scmodabc 2018-12-04 02:25:56 UTC
(In reply to PJ Fanning from comment #3)
> Maybe you should report this JAXB issue to IBM.

yes,I have make my effort to find how to report this issue to IBM, but the official forum always went wrong. It response 400 bad request with follow message :
Yikes — we didn't catch all of that.
Something went wrong someplace.
I'll try again some time later
Comment 5 Andreas Beeker 2018-12-09 02:11:21 UTC
fixed via r1848494

see also https://stackoverflow.com/questions/28860131/illegalstateexception-when-unmarshalling-from-child-node-with-xmleventreader

Currently the IBM build isn't successful, as there is an encryption bug ... but I'm on it
Comment 6 scmodabc 2018-12-10 07:55:25 UTC
(In reply to Andreas Beeker from comment #5)
> fixed via r1848494
> 
> see also
> https://stackoverflow.com/questions/28860131/illegalstateexception-when-
> unmarshalling-from-child-node-with-xmleventreader
> 
> Currently the IBM build isn't successful, as there is an encryption bug ...
> but I'm on it

Yes, it works!~~Thanks very much
But it still makes me confused why the event filterReader failed.
The answer from stackoverflow tells "when you pass it to the Unmarshaller it is going to ask for the next event",doesn't it means the reader "cursor" is at the position of, for example:
    <accentBorderCallout1>
   ↑here
and the unmarsheller call of next will return a START_ELEMENT?
I think it has the same meaning of the documentation of what filterRead.peek() say : "A call to peek() will be equal to the next return of next()".