Closed hernael closed 1 year ago
/cc @Karm (mandrel), @galderz (mandrel), @zakkak (mandrel)
What is the exact error is you use quarkus.native.additional-build-args=--initialize-at-run-time=com.squareup.wire.schema.RootKt,--allow-incomplete-classpath
?
And what is the native-image
command that has been executed (it's printed in the console)?
@zakkak should we close this as a duplicate?
Yes and no :)
Yes: This is not actually a Quarkus issue. We need to write a guide about how to approach this kind of issues and point people to it.
No: https://github.com/quarkusio/quarkus/issues/25526 is a feature request for allowing users to bypass such issues, which is something we would like them to do only as a last resort. So in that sense this issue is not a duplicate per se.
In the lack of a proper guide on how to approach this I suggest we keep this open and help @hernael find a fix. Unfortunately I won't be able to help with any of these in the next couple of days, but feel free to assign this to me.
Hi @geoand @zakkak
The error mentioned in first comment is error exact that is thrown with those arguments: quarkus.native.additional-build-args=--initialize-at-run-time=com.squareup.wire.schema.RootKt,--allow-incomplete-classpath
The native command is:
/opt/mandrel/bin/native-image -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dlogging.initial-configurator.min-level=500 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Davro.disable.unsafe=true -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=3 -J-Duser.language=es -J-Duser.country=VE -J-Dfile.encoding=UTF-8 --features=io.quarkus.caffeine.runtime.graal.CacheConstructorsFeature,io.quarkus.runner.Feature,io.quarkus.runtime.graal.ResourcesFeature,io.quarkus.runtime.graal.DisableLoggingFeature -J--add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED -J--add-opens=java.base/java.text=ALL-UNNAMED -J--add-opens=java.base/java.io=ALL-UNNAMED -J--add-opens=java.base/java.lang.invoke=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -H:+CollectImageBuildStatistics -H:ImageBuildStatisticsFile=process-transaction-application-2.1-SNAPSHOT-runner-timing-stats.json -H:BuildOutputJSONFile=process-transaction-application-2.1-SNAPSHOT-runner-build-output-stats.json -H:ReflectionConfigurationFiles=reflection-kafka-proto-config.json --initialize-at-run-time=com.squareup.wire.schema.RootKt --allow-incomplete-classpath -H:+AllowFoldMethods -J-Djava.awt.headless=true --no-fallback --link-at-build-time -H:+ReportExceptionStackTraces -H:-AddAllCharsets --enable-url-protocols=http,https -H:NativeLinkerOption=-no-pie -H:-UseServiceLoaderFeature -H:+StackTrace -H:AdditionalSecurityProviders=com.sun.security.sasl.Provider,org.apache.kafka.common.security.oauthbearer.internals.OAuthBearerSaslClientProvider,org.apache.kafka.common.security.scram.internals.ScramSaslClientProvider -J--add-exports=org.graalvm.sdk/org.graalvm.nativeimage.impl=ALL-UNNAMED -J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED --exclude-config io\.netty\.netty-codec /META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json --exclude-config io\.netty\.netty-handler /META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json process-transaction-application-2.1-SNAPSHOT-runner -jar process-transaction-application-2.1-SNAPSHOT-runner.jar
Important note, before updating there were no errors! and I used:
quarkus.platform.version: 2.13.2.Final graal.version: mandrel-java17-21.3.1.1-Final
I just made a change of quarkus and native compiler. Maybe the problem is mandrel
I don't know how 21.3 would work, but if I were you, I would look to your application, its dependencies and see why the jar containing okio.Options.Companion
might not be included in the list of jars that native image takes as input. I'm neither a Kotlin or Gradle expert.
No idea where you got the clue to add the quarkus-reactive-oracle-client
dependency but if that works, that's likely due to extension behind it, or the oracle client jar itself, which under the covers sets the allow incomplete classpath underneath. In any case, going down this path is not recommended.
A preferred approach might be to pass in --initialize-at-run-time=com.squareup
or a problematic package that is underneath that within the additional build arguments.
@galderz for some unknown reason, when i add the oracle dependency (quarkus-reactive-oracle-client), quarkus doesn't add --link-at-build-time
argument in native-image command. With that argument Mandrel ignores --initialize-at-run-time=com.squareup.wire.schema.RootKt
and throws exception, but if --link-at-build-time
argument is removed everything compiles fine.
It's like --link-at-build-time
has higher priority than --initialize-at-run-time=com.squareup.wire.schema.RootKt
in Mandrel
Change --initialize-at-run-time=com.squareup.wire.schema.RootKt
for --initialize-at-run-time=com.squareup
makes no difference, error still occurs.
@hernael can you please have a look at https://github.com/quarkusio/quarkus/pull/30716 and see if the information there are enough for you to overcome the issue? If not please provide feedback on how to improve it.
@zakkak I have a very similar issue (details are in zulip). In my case, a constructor is not found. I have verified that the class is on the classpath (mvn dependency:tree
shows the dependency that contains the class, is present). And I am also quite sure that there are no optional dependencies involved. Any hints on how to tackle this situation?
@turing85 Native reports.
@turing85 you might be hitting the issue I describe in https://github.com/oracle/graal/pull/4661, i.e., the error you are seeing might be missleading and the actual issue is different.
quarkus.platform.version: 2.13.2.Final graal.version: mandrel-java17-21.3.1.1-Final
Hmm, so you are using Quarkus 2.13.x
with 21.3
Mandrel? For 2.13
Quarkus it's recommended to use 22.3
mandrel. Have you tried that?
Edit: The original report mentions 22.3 GraalVM/Mandrel. It would be good to know which it is :)
Hmm, so you are using Quarkus
2.13.x
with21.3
Mandrel? For2.13
Quarkus it's recommended to use22.3
mandrel.
Just a clarification for the record.
For Quarkus 2.13.0 -- 2.13.3 it's actually recommended to use GraalVM/Mandrel 21.3 or 22.2. For 2.13.4 onwards, it's recommended to use 22.3. See https://github.com/graalvm/mandrel/wiki.
That being said, it's always recommended to use the latest release. Both 2.13.2 and 21.3 are outdated at this point, so please consider updating to Quarkus 2.13.7 or later and GraalVM/Mandrle 22.3 regardless of this issue.
@hernael is this still an issue for you?
I have the same issue:
com.pengrad.telegrambot.impl.TelegramBotClient is registered for linking at image build time by command line
Running: mvn package -Dquarkus.package.type=native -Dquarkus.native.additional-build-args="--initialize-at-run-time=com.pengrad.telegrambot.impl.TelegramBotClient, --allow-incomplete-classpath"
GraalVm: 22.3.r19-grl quarkus: 3.0.0.Alpha4
Hi @zakkak
yes, if there is already a quarkus property so that --link-at-build-time
argument is not added in native compile
no, if there is no way to remove that option
@hernael and @luis-rabock did you try following the short guide in https://quarkus.io/version/main/guides/native-reference#i-get-a-analysiserrorparsingerror-when-building-a-native-executable-due-to-an-unresolvedelementexception-what-can-i-do ?
If not, please do. If yes, please let me know what you tried and why it doesn't work so that we can improve that guide.
Thanks
@luis-rabock Please open a different issue to avoid creating confusion.
@hernael Please follow @zakkak's advice. Also, you still didn't provide the error(s) you get when you pass in --initialize-at-run-time=com.squareup.wire.schema.RootKt
or --initialize-at-run-time=com.squareup
. Sure, adding those flags might still cause errors but they should be slightly different and this is important for us to be able to help further. Or provide a reproducer for us to run.
@zakkak and @galderz adding --initialize-at-run-time=com.squareup.wire.schema.RootKt
argument is required, otherwise my application fails to compile natively indicating that it must be added. The problem is that when --link-at-build-time
argument is added then native compiler ignores the other argument and fails with same error as if the first argument had not been passed.
My application only works if --initialize-at-run-time=com.squareup.wire.schema.RootKt
argument is added and --link-at-build-time
is not added.
The problem is that currently quarkus almost always adds --link-at-build-time
argument, and the only way I found to stop it from adding it is to add the dependency on: quarkus-reactive-oracle-client
@hernael Can you please let us know if you tried following the guide I mention in https://github.com/quarkusio/quarkus/issues/30528#issuecomment-1419694995 and https://github.com/quarkusio/quarkus/issues/30528#issuecomment-1465940645?
For further help (if the guide doesn't help you resolve the issue) we will also need a reproducer (i.e. a maven/gradle project reproducing the error).
@zakkak and @galderz adding
--initialize-at-run-time=com.squareup.wire.schema.RootKt
argument is required, otherwise my application fails to compile natively indicating that it must be added. The problem is that when--link-at-build-time
argument is added then native compiler ignores the other argument and fails with same error as if the first argument had not been passed.My application only works if
--initialize-at-run-time=com.squareup.wire.schema.RootKt
argument is added and--link-at-build-time
is not added.
^ That sounds odd. By default GraalVM initializes classes at runtime unless you specify which classes to initialize at build time. What --link-at-build-time
does is change the default so that all classes are initialized at build time and only those specified otherwise are initialized at runtime. Hence, if --link-at-build-time
is not added, there would be no need to add any --initialize-at-run-time
for that class, unless there's some other thing at play here.
The problem is that currently quarkus almost always adds
--link-at-build-time
argument, and the only way I found to stop it from adding it is to add the dependency on:quarkus-reactive-oracle-client
That is not a "problem". It's designed that way. So far all the issues we are aware about build time initialized classes can be solved by marking the necessary classes to be initialized at runtime. To reiterate @zakkak said, we can't help further without a reproducer or some more tangible information from you (see previous comments).
One more thing you can try if you're feeling adventurous: download a GraalVM 23.0 snapshot and run with -H:+UseNewExperimentalClassInitialization
and see if your odd case is solved that way alternatively (see details).
^ That sounds odd. By default GraalVM initializes classes at runtime unless you specify which classes to initialize at build time. What --link-at-build-time does is change the default so that all classes are initialized at build time and only those specified otherwise are initialized at runtime. Hence, if --link-at-build-time is not added, there would be no need to add any --initialize-at-run-time for that class, unless there's some other thing at play here.
@galderz that's not true.
The build time initialization is done in https://github.com/quarkusio/quarkus/blob/d08d31fa598cbad2a2b275cd313e707b4d1acab2/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageFeatureStep.java#L98-L99
--link-at-build-time
is not related to build-time initialization. --link-at-build-time
essentially instructs GraalVM/Mandrel to fail if a reachable (according to the static analysis) class is not available on the classpath at build time (regardless if the said class is run-time or build-time initialized).
To my understanding this issue is not a run-time vs build-time initialization issue, but an incomplete classpath initialization issue. https://quarkus.io/version/main/guides/native-reference#i-get-a-analysiserrorparsingerror-when-building-a-native-executable-due-to-an-unresolvedelementexception-what-can-i-do is meant to help developers address such issues.
Ah yes, thx for correcting me @zakkak :)
@hernael Have you checked where the jar that contains okio.Options.Companion
is and what kind of dependency com.squareup.wire.schema.RootKt
has on it? Even if the class is not really used by your application, adding the jar that contains the okio.Options.Companion
version that com.squareup.wire.schema.RootKt
expects to the classpath should work.
Closing for lack of feedback
@galderz @geoand Still have the same error when using:
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.7.0</version>
</dependency>
Error:
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved type during parsing: javax.ws.rs.core.Context. This error is reported at image build time
because class org.glassfish.jersey.inject.hk2.ContextInjectionResolverImpl is registered for linking at image build time by command line
I tried to set --initialize-at-run-time
in application.properties but no success.
quarkus.native.additional-build-args=--initialize-at-run-time=org.glassfish.jersey.inject.hk2.ContextInjectionResolverImpl
One more thing you can try if you're feeling adventurous: download a GraalVM 23.0 snapshot and run with
-H:+UseNewExperimentalClassInitialization
and see if your odd case is solved that way alternatively (see details).
@floka94 ^
Actually, the new class initialization method is on by default on master graal master since today. You can wait a few days, download a nightly build from here and you don't have to pass any new parameters to try the new class initialization mechanism.
Thx, i will try!
Describe the bug
In native build process, quarkus add --link-at-build-time argument. But in my case that argument throws:
error even stays if i add the property:
the way I got it NOT to be added
--link-at-build-time
argument to native build phase was to add a dependency:There must be a solution other than adding a dependency so that the
--link-at-build-time argument
is removed in native build.Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
openjdk version "17.0.5"
GraalVM version (if different from Java)
mandrel-java17-22.3.0.1-Final
Quarkus version or git rev
2.16.0.CR1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.6
Additional information
No response