Reputation: 35
I have a JavaFX application that is based on Spring Framework. I'm trying to make it working as an Android application.
I'm using gradle and so the gluonfx-gradle-plugin. (v 1.0.18)
When running the nativeCompile task, I get the following error :
[mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] Caused by: 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. Object has been initialized by the io.netty.util.NetUtil class initializer with a trace:
[mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at ch.qos.logback.classic.Logger.(Logger.java:105) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at ch.qos.logback.classic.Logger.createChildByName(Logger.java:360) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at ch.qos.logback.classic.LoggerContext.getLogger(LoggerContext.java:156) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at ch.qos.logback.classic.LoggerContext.getLogger(LoggerContext.java:54) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:391) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at io.netty.util.internal.logging.Slf4JLoggerFactory.newInstance(Slf4JLoggerFactory.java:49) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at io.netty.util.internal.logging.InternalLoggerFactory.getInstance(InternalLoggerFactory.java:134) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at io.netty.util.internal.logging.InternalLoggerFactory.getInstance(InternalLoggerFactory.java:127) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at io.netty.util.NetUtilInitializations.(NetUtilInitializations.java:38) [mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] at io.netty.util.NetUtil.(NetUtil.java:145)
[mer. avr. 19 15:21:06 CEST 2023][INFO] [SUB] . To fix the issue mark ch.qos.logback.classic.Logger for build-time initialization with --initialize-at-build-time=ch.qos.logback.classic.Logger or use the the information from the trace to find the culprit and --initialize-at-run-time= to prevent its instantiation.
I have tried to solve the problem adding this block in gluonfx block of the build.gradle :
gluonfx {
...
compilerArgs = ["--trace-object-instantiation=ch.qos.logback.classic.Logger",
"--initialize-at-run-time=ch.qos.logback.classic.Logger"
]
...
}
But this doesn't produce any change on the nativeCompile result.
In addition to this problem. I have a lot of Warning :
[mer. avr. 19 15:33:19 CEST 2023][INFO] [SUB] Warning: Could not register io.netty.handler.codec.compression.Lz4FrameDecoder: queryAllPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: net/jpountz/lz4/LZ4Exception. [mer. avr. 19 15:33:19 CEST 2023][INFO] [SUB] Warning: Could not register io.netty.handler.codec.compression.Lz4FrameDecoder: queryAllPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: net/jpountz/lz4/LZ4Exception. [mer. avr. 19 15:33:19 CEST 2023][INFO] [SUB] Warning: Could not register io.netty.handler.codec.compression.Lz4FrameEncoder: queryAllPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: net/jpountz/lz4/LZ4Exception. [mer. avr. 19 15:33:19 CEST 2023][INFO] [SUB] Warning: Could not register io.netty.handler.codec.compression.Lz4FrameEncoder: queryAllPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: net/jpountz/lz4/LZ4Exception. [mer. avr. 19 15:33:19 CEST 2023][INFO] [SUB] Warning: Could not register io.netty.handler.codec.marshalling.CompatibleMarshallingDecoder: queryAllPublicMethods for reflection. Reason: java.lang.NoClassDefFoundError: org/jboss/marshalling/ByteInput. ...
Are there important ?
Please, can someone give me some guidance to solve this problem ?
Thank you.
Edit :
I have solved this problem following this [issue] (javafx graalvm Error: Classes that should be initialized at run time got initialized during image building). For me, what worked was to add in the build.gradle :
compilerArgs = ["--trace-object-instantiation=ch.qos.logback.classic.Logger",
"--allow-incomplete-classpath",
"--initialize-at-run-time=io.netty.util.internal.logging.Log4JLogger"]
And the file resources/META-INF/substrate/config/initbuildtime with the following content :
org.slf4j.LoggerFactory
ch.qos.logback.classic.Logger
org.slf4j.simple.SimpleLogger
org.slf4j.impl.StaticLoggerBinder
ch.qos.logback.core.spi.AppenderAttachableImpl
ch.qos.logback.core.status.StatusBase
ch.qos.logback.classic.Level
ch.qos.logback.core.status.InfoStatus
ch.qos.logback.classic.PatternLayout
ch.qos.logback.core.CoreConstants
org.slf4j.MDC
ch.qos.logback.core.util.StatusPrinter
ch.qos.logback.core.util.Loader
Doing this, I can create the executable (nativeLink).
But when running the application with nativeRun, the application stop immediately with the following error :
[mer. avr. 19 18:29:00 CEST 2023][INFO] [SUB] Caused by: java.lang.NoSuchMethodException: org.apache.logging.log4j.message.DefaultFlowMessageFactory.()
I'm using @Log4J2 with lombok. It seems something was not correctly compiled.
Upvotes: 1
Views: 238