I'm encountering an issue when attempting to use RestClientBuilder in my Java code to build a client with MicroProfile. I'm receiving the error message "No RestClientBuilderResolver implementation found!" Here's the segement that causes the issue:
MyClient myClient = RestClientBuilder.newBuilder()
.baseUri(new URI(Url))
.build(MyClient.class);
And here's my MyClient interface:
@Path("/root")
@RegisterRestClient
@ClientHeaderParam(name = "x-api-key", value = MyKey)
public interface MyClient {
@POST
@Path("/endpoint1")
public MyObj getDeviceState(JsonObject body);
@POST
@Path("/endpoint2")
public MyObj getGatewayState(JsonObject body);
}
I've verified that the dependencies for the necessary are correctly included. However, despite this, I'm still encountering the error mentioned above.
I am using Payara 6.2023.11, jakarta ee 10 and i am using the following dependencies
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
<artifactId>microprofile-rest-client-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>5.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
I tried multiple versions of them and also used them alone or together.
I also have tested to use
RestClientBuilder builder = RestClientBuilderResolver.instance().newBuilder();
MyClient myClient = builder
.baseUri(new URI(URL))
.build(MyClient.class);
and here I could go the the implementation of RestClientBuilderResolver which doesn't make sense to me.
I tried to do a small side project where I did the same and it worked. Then I added all the dependencies that were on my Main project and it still worked, so it don't think there is a dependency conflict.
Could someone guide me on what might be causing this issue and how I could resolve it? Any help would be greatly appreciated. Thank you!