wiremock / wiremock-grpc-extension

WireMock Extension: gRPC mocking
https://wiremock.org/docs/grpc/
Apache License 2.0
15 stars 9 forks source link

Upgrading 0.7.0 -> 0.8.0 errors #106

Closed edeandrea closed 2 months ago

edeandrea commented 3 months ago

Proposal

I updated my application from 0.7.0 to 0.8.0 and my tests now fail. I didn't make any changes in my project other than upgrading the version of the wiremock-grpc dependency.

java.lang.reflect.InvocationTargetException
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at io.quarkus.test.common.TestResourceManager.buildTestResourceEntry(TestResourceManager.java:259)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: io/grpc/protobuf/services/ProtoReflectionServiceV1
    at org.wiremock.grpc.internal.GrpcFilter.buildServices(GrpcFilter.java:137)
    at org.wiremock.grpc.internal.GrpcFilter.loadFileDescriptors(GrpcFilter.java:56)
    at org.wiremock.grpc.internal.GrpcHttpServerFactory.loadFileDescriptors(GrpcHttpServerFactory.java:71)
    at org.wiremock.grpc.internal.GrpcHttpServerFactory$1.decorateMockServiceContextBeforeConfig(GrpcHttpServerFactory.java:90)
    at com.github.tomakehurst.wiremock.jetty11.Jetty11HttpServer.addMockServiceContext(Jetty11HttpServer.java:250)
    at com.github.tomakehurst.wiremock.jetty11.Jetty11HttpServer.createHandler(Jetty11HttpServer.java:199)
    at com.github.tomakehurst.wiremock.jetty.JettyHttpServer.<init>(JettyHttpServer.java:100)
    at com.github.tomakehurst.wiremock.jetty11.Jetty11HttpServer.<init>(Jetty11HttpServer.java:76)
    at org.wiremock.grpc.internal.GrpcHttpServerFactory$1.<init>(GrpcHttpServerFactory.java:84)
    at org.wiremock.grpc.internal.GrpcHttpServerFactory.buildHttpServer(GrpcHttpServerFactory.java:84)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:81)
    at io.quarkus.sample.superheroes.fight.LocationsWiremockGrpcServerResource.<init>(LocationsWiremockGrpcServerResource.java:29)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: io.grpc.protobuf.services.ProtoReflectionServiceV1
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:561)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:509)
    ... 23 more

Reproduction steps

See https://github.com/quarkusio/quarkus-super-heroes/pull/1160 and https://github.com/quarkusio/quarkus-super-heroes/actions/runs/10578222706/job/29307872256?pr=1160

Test classes: https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-fights/src/test/java/io/quarkus/sample/superheroes/fight/client/LocationClientTests.java and https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-fights/src/test/java/io/quarkus/sample/superheroes/fight/LocationsWiremockGrpcServerResource.java

  1. Clone https://github.com/quarkusio/quarkus-super-heroes
  2. gh pr checkout 1160
  3. cd rest-fights
  4. ./mvnw clean test -Dtest= LocationClientTests

References

No response

leeturner commented 2 months ago

Hi @edeandrea Many thanks for posting the issue. This looks like we have bumped a version of our dependencies to one higher than the version Quarkus is using. It looks like Quarkus is using 1.65.1 of io.grpc.grpc-services and the WireMock gRPC extension is using the latest (1.66.0)

Do you know if Quarkus are planning on upgrading the gRPC services dependency ? This should fix the issue. Adding a dependency override in the rest-flights pom allows all the tests to pass:

<dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-services</artifactId>
      <version>1.66.0</version>
</dependency>

Other than that, we could try using the standalone version of wiremock-grpc-extension but I would need to look into this further.

edeandrea commented 2 months ago

Thank you @leeturner for looking into this. I will check on the quarkus side and see what the plans are

edeandrea commented 2 months ago

I started a conversation about this here: https://quarkusio.zulipchat.com/#narrow/stream/187038-dev/topic/io.2Egrpc.3Agrpc-services.20versioning.3F

edeandrea commented 2 months ago

I can verify that updating the version works as expected, so I'll go ahead and close this out.