Error while converting xlsx stream to Workbook while migrating from AEM 6.3 to 6.4 | Community
Skip to main content
debasis-swain
Level 2
May 3, 2019 8:36 AM UTC
Solved

Error while converting xlsx stream to Workbook while migrating from AEM 6.3 to 6.4

Hi Team,

Recently I moved my project base from AEM6.3 to 6.4. While doing the sanity testing I found that the application is throwing error while converting the xlsx filestream to Apache POI Workbook object.

Below is the code.

It's working in AEM6.3 but not in AEM6.4

Resource fileResource = resourceResolver.getResource(path);

            Asset asset = null;

            asset = fileResource.adaptTo(Asset.class);

            InputStream fileStream = asset.getOriginal().getStream();

Workbook excelWorkBook = new XSSFWorkbook(fileStream );

In POM I am using the "com.adobe.granite.poi" dependency.

Below is the error that I am getting.

org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException

                at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63) [com.adobe.granite.poi:2.0.24]

                at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:604) [com.adobe.granite.poi:2.0.24]

                at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:186) [com.adobe.granite.poi:2.0.24]

                at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:296) [com.adobe.granite.poi:2.0.24]

                ...

Caused by: java.lang.reflect.InvocationTargetException: null

                at sun.reflect.GeneratedConstructorAccessor142.newInstance(Unknown Source)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

                at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56) [com.adobe.granite.poi:2.0.24]

                at org.apache.poi.POIXMLFactory.createDocumentPart(POIXMLFactory.java:60) [com.adobe.granite.poi:2.0.24]

                ... 141 common frames omitted

Caused by: java.lang.ClassCastException: org.apache.xmlbeans.impl.schema.SchemaTypeImpl cannot be cast to org.apache.xmlbeans.impl.values.TypeStoreUserFactory

                at org.apache.xmlbeans.impl.store.Xobj.setStableType(Xobj.java:1402

                at org.apache.xmlbeans.impl.store.Cur.setType(Cur.java:2500)

                at org.apache.xmlbeans.impl.store.Cur.setType(Cur.java:2485)

                at org.apache.xmlbeans.impl.store.Locale.autoTypeDocument(Locale.java:358)

                at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1390)

                at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1369)

                at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:370)

                at org.apache.poi.POIXMLTypeLoader.parse(POIXMLTypeLoader.java:144) [com.adobe.granite.poi:2.0.24]

                at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source) [com.adobe.granite.poi:2.0.24]

                at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:84) [com.adobe.granite.poi:2.0.24]

                ... 146 common frames omitted

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Jun 2, 2020 8:53 AM UTC

Answerd by debasiss6552584

 

Finally I got the root cause of the issue.

The issue was due to a wrong xmlbean dependency being added as part of com.adobe.granite.poi. The correct version of com.adobe.granite.poi should be 2.0.24 when you check in the http://localhost:4502/system/console/depfinder and search for org.apache.xmlbeans.This is happening when I upload AEM forms service package.

 

Now without the AEM forms service package I am able to successfully execute the xlxs reading .

 

Thanks all of you for pitching in.

Kautuk Sahni

7 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
Jun 2, 2020 8:53 AM UTC

Answerd by debasiss6552584

 

Finally I got the root cause of the issue.

The issue was due to a wrong xmlbean dependency being added as part of com.adobe.granite.poi. The correct version of com.adobe.granite.poi should be 2.0.24 when you check in the http://localhost:4502/system/console/depfinder and search for org.apache.xmlbeans.This is happening when I upload AEM forms service package.

 

Now without the AEM forms service package I am able to successfully execute the xlxs reading .

 

Thanks all of you for pitching in.

Translate
Kautuk Sahni
cquser1
Level 7
Feb 19, 2020 8:04 AM UTC

Hi Debasis,

 

Thanks, your post really helped.

Translate
debasis-swain
Level 2
May 7, 2019 6:12 AM UTC

Finally I got the root cause of the issue.

The issue was due to a wrong xmlbean dependency being added as part of com.adobe.granite.poi. The correct version of com.adobe.granite.poi should be 2.0.24 when you check in the http://localhost:4502/system/console/depfinder and search for org.apache.xmlbeans.This is happening when I upload AEM forms service package.

Now without the AEM forms service package I am able to successfully execute the xlxs reading .

Thanks all of you for pitching in.

Translate
smacdonald2008
Level 10
May 3, 2019 7:05 PM UTC

We have no Doc for this use case that i can point you to.

Translate
Level 2
May 3, 2019 3:07 PM UTC

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->

<dependency>

    <groupId>org.apache.poi</groupId>

    <artifactId>poi-ooxml</artifactId>

    <version>4.1.0</version>

</dependency>

Can you check your dependency? This is the dependency for it.

Translate
debasis-swain
Level 2
May 3, 2019 2:50 PM UTC

I tried that also it's not working.

Translate
Level 2
May 3, 2019 9:07 AM UTC

Can you try this
Workbook workbook = WorkbookFactory.create(fileStream) ??

Translate