-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Runtime fail on native-image application using Apache POI #2187
Comments
Simillar to #1993 but this uses Java 11. |
I see that you attached the |
@sgyeme in my experience, the ClassCastException is always caused by missing reflection configuration. For yours specifically, |
I'll also add that you can initialize For this issue itself: Other than that, you have a few org.apache.xmlbeans classes in your config that I didn't need, but that's probably required for the .toString call. The config itself looks ok, and for me, the agent was able to get all the config I needed. (I also use XSSFWorkbook, so I don't see any reason why that would not be the case for you). If the suggestion from @cstancu doesn't work, you may want to try POI 5.0.0, I have since moved on to it and I find it a tiny bit more native-image friendly, although most of the config will stay the same. |
@kkriske could you please share the configuration you have for |
As stated in my previous message, just initializing everything at build-time: # native-image.properties
Args = --initialize-at-build-time=\
org.apache.commons.compress I'm currently using That's all, but fair warning, initializing entire packages at built-time instead of letting GraalVM detect what is safe to initialize is discouraged as it may introduce hard to debug bugs. As far as I know, only Are you running into any specific issues with commons-compress? |
@kkriske thank you for the prompt response. I am in the process of migrating some microservices to native (using poi-ooxml 5.2.0), and I get the following error during Runtime:
UPDATE: After adding the
In my pom.xml, I only have the following dependency:
|
POI requires resources & reflection at runtime so you need to provide the config for that. I've previously explained a bit about POI and native-image here: #3191 |
@kkriske I finally managed to resolve the issues by using the native-image-agent. Thanks for the feedback. |
@kkriske I am using an Apache POI lib in Micronaut project which I am building a Graalvm native-image. But the issue is there are tons of classes and method in POI lib which are using the reflection, and POI dynamically uses any of those classes to read the excel file. I am developing an application where end users will upload and read the excel files, and thus I will need the reflection configs of all the classes and method of POI lib. How can I get those configs without actually executing that code? |
Could you explain ? Which command do you run ? please |
Using the |
Describe GraalVM and your environment :
java -Xinternalversion
:Have you verified this issue still happens when using the latest snapshot?
It has been verified using GraalVM CE 20.1.0-dev-20200225_0946, the latest snapshot at the time of reporting.
Describe the issue
The example application instantiates an Apache POI class. Its dependencies use reflection, so a reflection config has to be generated for the native-image build. When running the built executable, the following exception occurs:
Describe the full native-image command
Code snippet or code repository that reproduces the issue
Steps to reproduce the issue
graalvm_ni_apachepoi_failure
and pastesrc\main\java\graalvm_ni_apachepoi_failure\App.java
,build.gradle
,native-image\META-INF\native-image\jni-config.json
,native-image\META-INF\native-image\proxy-config.json
,native-image\META-INF\native-image\reflect-config.json
,native-image\META-INF\native-image\resource-config.json
provided above into itgradle clean build
into thegraalvm_ni_apachepoi_failure
directorygu install native-image
graalvm_ni_apachepoi_failure\native-image
java -agentlib:native-image-agent=config-output-dir=META-INF\native-image -cp "..\build\distributions\graalvm_ni_apachepoi_failure\lib\*" graalvm_ni_apachepoi_failure.App
native-image -cp "..\build\distributions\graalvm_ni_apachepoi_failure\lib\*" --no-fallback --verbose graalvm_ni_apachepoi_failure.App
Expected behavior
The application should have printed the string representation of a XSSFWorkbook object.
The text was updated successfully, but these errors were encountered: