Closed rhauch closed 4 months ago
It turns out the problem was that my application used a parent POM that had a slightly older version of com.google.protobuf:protobuf-java
(3.19.6) in the dependencyManagement
section than what is required by com.apollographql.federation:federation-graphql-java-support
(3.25.2).
Since there were no other dependencies (including no direct dependency), the parent POM's version was used instead of the correct version. But this was difficult to discover, since Maven dependency analysis did not help highlight what was causing the earlier version to be used:
$ mvn dependency:tree -Dincludes=com.google.protobuf:protobuf-java
...
\- io.quarkus:quarkus-smallrye-graphql:jar:3.10.1:compile
\- io.smallrye:smallrye-graphql-cdi:jar:2.8.4:compile
\- io.smallrye:smallrye-graphql:jar:2.8.4:compile
\- com.apollographql.federation:federation-graphql-java-support:jar:4.4.0:compile
\- com.google.protobuf:protobuf-java:jar:3.19.6:compile
As a result, when GraalVM is looking at dependencies, there must have been some com.google.protobuf:protobuf-java
methods or types used by the generated protobuf code in com.apollographql.federation:federation-graphql-java-support:jar
that must have changed or been added since version 3.19.6.
So an easy way to fix this is to add a direct dependency to my application to override the dependency :
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.2</version>
</dependency>
To be honest, I'm not sure what improvements to suggest, other than just keeping this issue available so that others running into the same error might find it and have some information for what workarounds to consider. So I'll add this information and close this issue.
If anyone can think of a change to existing resources/docs that might help, please reopen.
Summary
We're successfully using SmallRye GraphQL in our application:
and are able to run the application as a Java application w/ JRE. However, we are unable to build a native image due to this failure (or others very similar to this, see Details section below):
Prior to adding the
io.quarkus:quarkus-smallrye-graphql
dependency, we are able to build and run the native application, so it seems like there is a problem with building a native application while usingio.quarkus:quarkus-smallrye-graphql
.The
mdg.engine.proto.Reports
class is included in thecom.apollographql.federation:federation-graphql-java-support:4.4.0
artifact, and themdg.engine.proto
code is generated from a protobuf file. So per the Quarkus Native Reference guide we tried adding this and the protobuf library as explicit dependencies.Any suggestions or other workarounds I can try? I guess I would have thought this would have worked given that these are dependencies of
io.quarkus:quarkus-smallrye-graphql
.FWIW, https://github.com/smallrye/smallrye-graphql/issues/1845 is a similar issue, though the problematic class was from the tracing service. This seems far more essential.
Details
When just including the
taken from this output:
The
mdg.engine.proto.Reports
class is included in thecom.apollographql.federation:federation-graphql-java-support:4.4.0
artifact, and themdg.engine.proto
code is generated from a protobuf file.The Quarkus Native Reference guide talks about Quarkus using GraalVM’s
--link-at-build-time
parameter, and how this doesn't handle optional dependencies with a few ways of trying to change dependencies from optional to required.Adding this did not meaningfully change the failure:
with or without the
<optional>
element. Also adding this (with or without<optional>
):also had no meaningful effect, other than adding other unresolved methods in the
mdg.engine.proto.Reports$Trace
code. For example:or
or