Bug 66653 - XDDFValueAxis setMajorUnit gets an exception on execution
Summary: XDDFValueAxis setMajorUnit gets an exception on execution
Status: RESOLVED INFORMATIONPROVIDED
Alias: None
Product: POI
Classification: Unclassified
Component: XDDF (show other bugs)
Version: unspecified
Hardware: Macintosh All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-16 18:16 UTC by jrmelom
Modified: 2023-06-16 19:10 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jrmelom 2023-06-16 18:16:34 UTC
The following code works in 4.1.2.  It does not work in 5.0.0 or higher:    

        XDDFValueAxis xAxis = chart.createValueAxis(AxisPosition.BOTTOM);
        XDDFValueAxis yAxis = chart.createValueAxis(AxisPosition.LEFT);

        xAxis.setTitle("Seconds Into Run");
        double xAxisMajorUnits = 300.0;
        xAxis.setMajorUnit(xAxisMajorUnits);

It gets this exception when executing

Exception in thread "main" org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Could not locate compiled schema resource org/apache/poi/schemas/ooxml/system/ooxml/staxisunit6cc7type.xsb (org.apache.poi.schemas.ooxml.system.ooxml.staxisunit6cc7type) - code 0
        at org.apache.xmlbeans.impl.schema.XsbReader.<init>(XsbReader.java:63)
        at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.resolveHandle(SchemaTypeSystemImpl.java:931)
        at org.apache.xmlbeans.SchemaComponent$Ref.getComponent(SchemaComponent.java:111)
        at org.apache.xmlbeans.SchemaType$Ref.get(SchemaType.java:1072)
        at org.apache.xmlbeans.impl.schema.SchemaPropertyImpl.getType(SchemaPropertyImpl.java:85)
        at org.apache.xmlbeans.impl.schema.SchemaTypeImpl.createAttributeType(SchemaTypeImpl.java:1055)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.create_attribute_user(XmlObjectBase.java:898)
        at org.apache.xmlbeans.impl.store.Xobj.getUser(Xobj.java:1598)
        at org.apache.xmlbeans.impl.store.Xobj.add_attribute_user(Xobj.java:2167)
        at org.openxmlformats.schemas.drawingml.x2006.chart.impl.CTAxisUnitImpl.setVal(CTAxisUnitImpl.java:67)
        at org.apache.poi.xddf.usermodel.chart.XDDFValueAxis.setMajorUnit(XDDFValueAxis.java:154)
        at FilesToExcel.AWSCloudwatchTSVToExcel.writeToExcel(AWSCloudwatchTSVToExcel.java:143)
        at FilesToExcel.AWSCloudwatchTSVToExcel.main(AWSCloudwatchTSVToExcel.java:56)
Comment 1 jrmelom 2023-06-16 18:38:45 UTC
further searching online found a similar bug resolved by including poi-ooxml-full in my Gradle dependencies:

dependencies
{
    implementation 'org.apache.poi:poi:5.2.2'
    implementation 'org.apache.poi:poi-ooxml-full:5.2.2'
    implementation 'org.apache.poi:poi-ooxml:5.2.2'
}


My code works now.

Sorry for the false alarm.
Comment 2 PJ Fanning 2023-06-16 19:10:14 UTC
poi--oxml defaults to having a dependency on poi-ooxml-lite.
poi-ooxml-lite is a subset of poi-ooxml-full.
poi-ooxml-lite only has the most commonly used XMLBeans for POI.
poi-ooxml-full is big so that's why we default to poi-ooxml-lite.

If you choose to use poi-ooxml-full, it is a good idea to exclude poi-ooxml-lite.

I've made a change to POI so that v5.2.4 will put that missing staxisunit6cc7type.xsb in poi-ooxml-lite.