I have a project that consumes an api and am struggling to get the Rest Client injected into my service.
(to note, i am mainly doing what i did in another instance that works however I can’t pinpoint what’s wrong here to make this one fail)
My Client interface:
@org.eclipse.microprofile.rest.client.inject.RegisterRestClient( configKey = "my.feature-service.baseUrl" ) @org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders(MyCustomHeadersFactory.class) @javax.ws.rs.Consumes({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"}) @javax.ws.rs.Produces({"application/vnd.cust.my-service-config+json;version=1.0;charset=UTF-8"}) public interface FeatureServiceClient { @javax.ws.rs.GET @javax.ws.rs.Path("/v1/my/feature") Uni<List<MyDto>> getPossibleFeatures(); //and several other methods }
on my consuming side I have:
@javax.enterprise.context.ApplicationScoped public class MyService { @org.eclipse.microprofile.rest.client.inject.RestClient FeatureServiceClient serviceClient; }
however when it tries to get initialised I am getting:
Caused by: java.lang.IllegalArgumentException: Not a REST client interface: interface my.feature.FeatureServiceClient. No @Path annotation found on the class or any methods of the interface and no HTTP method annotations (@POST, @PUT, @GET, @HEAD, @DELETE, etc) found on any of the methods at org.jboss.resteasy.reactive.client.impl.ClientProxies.get(ClientProxies.java:26) at org.jboss.resteasy.reactive.client.impl.WebTargetImpl.proxy(WebTargetImpl.java:382) at io.quarkus.rest.client.reactive.runtime.RestClientBuilderImpl.build(RestClientBuilderImpl.java:273) at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.build(RestClientCDIDelegateBuilder.java:76) at io.quarkus.rest.client.reactive.runtime.RestClientCDIDelegateBuilder.createDelegate(RestClientCDIDelegateBuilder.java:57) at io.quarkus.rest.client.reactive.runtime.RestClientReactiveCDIWrapperBase.<init>(RestClientReactiveCDIWrapperBase.java:16) at my.feature.MyFeatureClient$$CDIWrapper.<init>(FeatureServiceClient$$CDIWrapper.zig:21) at my.feature.MyFeatureClient$$CDIWrapper_ClientProxy.<init>(MyFeatureClient$$CDIWrapper_ClientProxy.zig:28) at my.feature.MyFeatureClient$$CDIWrapper_Bean.proxy(FeatureServiceClient$$CDIWrapper_Bean.zig:40) at my.feature.MyFeatureClient$$CDIWrapper_Bean.get(FeatureServiceClient$$CDIWrapper_Bean.zig:243) at my.feature.MyFeatureClient$$CDIWrapper_Bean.get(FeatureServiceClient$$CDIWrapper_Bean.zig:259) at my.consumer.Myservice_Bean.create(MyService_Bean.zig:175) ... 67 more
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> <quarkus.platform.version>2.3.0.CR1</quarkus.platform.version>
Advertisement
Answer
So, found the solution.
I added the following build plugins to the module contianing my Client interface
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${compiler-plugin.version}</version> <configuration> <parameters>${maven.compiler.parameters}</parameters> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${org.projectlombok.version}</version> </path> </annotationProcessorPaths> <!-- the parameters=true option is critical so that RESTEasy works fine --> <parameters>true</parameters> </configuration> </plugin> <plugin> <groupId>org.jboss.jandex</groupId> <artifactId>jandex-maven-plugin</artifactId> <version>1.1.0</version> <executions> <execution> <id>make-index</id> <goals> <goal>jandex</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
not entirely sure which of those caused the error to get solved really and i wouldn’t expect such an error for any of those being missing.