-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting ClassCastException in native mode when using Apache POI #10891
Comments
This isn't really a Quarkus bug, as there is no Quarkus extension supporting Apache POI. Furthermore, not having the sources (https://repo1.maven.org/maven2/org/apache/poi/poi-ooxml-schemas/4.0.1/) does not make it really easy for us to help |
I understand. The only reason I filed this as a bug is because the same code runs as native when I compile it directly with GraalVM via its Maven plugin and without any Quarkus dependencies (attached as txt file). It also runs with no issue in JVM. If I understand correctly, this issue can be resolved via reflection-config.json. If it is, can you suggest what I need to put in this file to resolve confusion with classes (ClassCastException)? Because this looks like reflection issue. Please see stack trace and generated reflection-config file I attached to issue. |
It's very hard to tell without having the actual sources. |
I guess, although I personally don't have the time currently to go through the various hoops of trying to figure it out, sorry. Maybe someone else has an idea of how to quickly fox it? @sberyozkin perhaps you have an answer off the top of your head? |
I can help if you outline course of actions for issues of this kind. |
I am not sure what is causing it, so I don't have any specific recommendations. |
Something to keep in mind, from what I mentioned above. I was able compile this code to native executable using GraalVM Maven plugin in the POM I provided. And run it successfully. I can zip and provide the whole project, if this will help. Thanks com.oracle.substratevm |
I understand that, thanks. The thing is that the more classes are on the classpath can alter the native image behavior. Also, are you sure you used the same GraalVM version as Quarkus is using? |
This is from command line for working build. Executing: /home/yury/graalvm-ce-java11-20.1.0/bin/native-image -cp /home/yury/.m2/repository/org/apache/poi/poi-ooxml/4.1.2/poi-ooxml-4.1.2.jar:/home/yury/.m2/repository/org/apache/poi/poi/4.1.2/poi-4.1.2.jar:/home/yury/.m2/repository/commons-codec/commons-codec/1.13/commons-codec-1.13.jar:/home/yury/.m2/repository/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar:/home/yury/.m2/repository/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar:/home/yury/.m2/repository/com/zaxxer/SparseBitSet/1.2/SparseBitSet-1.2.jar:/home/yury/.m2/repository/org/apache/poi/poi-ooxml-schemas/4.1.2/poi-ooxml-schemas-4.1.2.jar:/home/yury/.m2/repository/org/apache/xmlbeans/xmlbeans/3.1.0/xmlbeans-3.1.0.jar:/home/yury/.m2/repository/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar:/home/yury/.m2/repository/com/github/virtuald/curvesapi/1.06/curvesapi-1.06.jar:/mnt/c/development/graal/target/excel-gen-0.1.jar -ea -H:Class=graal.test.ExcelGen |
Hello, I have an open source application project where you can reproduce the problem. https://github.com/ncomet/excel2adoc launching the
will work, but if you go to "Releases" in the github project, the platform dependent native binaries will produce this stack:
I tried adding more dependencies to the project
But without any success. |
Hi ncomet, were you able to find a fix for this in the end? |
Unfortunately no. I did not have time to look any further into this. |
Hey @yrostov I was able to create and read some various excel files with Poi and Quarkus and got the same error before. Unfortunately I do not know anymore how I solved this error concret, but add some classes to reflect-config.json was the solution. Importand notice: We used Poi 4.1.2 from Quarkus Tika Extension 1.0.3 Attached you get some snips from my reflect-config.json which could probably help you. Unfortunately I can not provide the whole config. But nevermind, the best way to create your reflect-config.json or at least figure out which classes are missing in your config is to run your application with native-image agent from graalvm. |
Thanks @knuspertante much! Your reflect-conflig file saved my day. |
This is not a Quarkus bug. If someone is interested in creating a POI extension to centralize the reflection config, that would be awesome. Closing this. If someone is interested, please create an |
Describe the bug
Code is using org.apache.poi / poi-ooxml libraries and running as AWS Lambda native executable. When code executes Workbook workbook = new XSSFWorkbook() line it gets ClassCastException exception
Expected behavior
Expect to be able to create object of Workbook class
Actual behavior
Getting java.lang.ClassCastException: org.apache.xmlbeans.impl.values.XmlComplexContentImpl cannot be cast to org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook. See attached file with full stack trace.
To Reproduce
Code is based on generated project from Amazon Lambda with RESTEasy, etc guide with addition of Apache POI dependency and code that creates Excel Workbook
Environment (please complete the following information):
uname -a
orver
: Linux Inspiron-15 4.4.0-18362-Microsoft Agroal extension url configurable independent of configuration subsystem #836-Microsoft Mon May 05 16:04:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linuxjava -version
: OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)mvnw --version
orgradlew --version
): Apache Maven 3.6.3Additional context
See attached reflect-config.txt based on running agent.
stack.txt
reflect-config.txt
The text was updated successfully, but these errors were encountered: