简体   繁体   中英

GraalVM (native-image) can not compile logback dependencies

I'm using the current version of community edition: GraalVM/native-image 22.1.0

My project has a dependency to the logging framework logback (version 1.2.3)

If I want to compile my "all-in-one" jar with graalVM the native-image complains:

Error: java.util.concurrent.ExecutionException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: No instances of ch.qos.logback.classic.Logger are allowed in the image heap as this class should be initialized at image runtime. To see how this object got instantiated use --trace-object-instantiation=ch.qos.logback.classic.Logger.

I played around with many different permutations of settings eg --initialize-at-run-time=\<complete list of logback classes\> and --initialize-at-run-time

I tried to generate a reflection configuration file with

java -agentlib:native-image-agent=config-output-dir=META-INF/native-image -jar build/myjar-all.jar

and added it to the config file with

-H:ReflectionConfigurationFiles=reflect-config.json

But without success. Always getting different error messages all related to logback.

So my question:

Has anyone got logback successfully compiled with graalvm before?

You should add logback to --initialize-at-build-time :

--initialize-at-build-time=ch.qos.logback

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM