1

I am trying to create a first-time Quarkus project. In this project I need to import a Jax-rs service interface from another package, and use it in a client in order to call a service. As such, I am using the RestClientBuilder, as opposed to the @RegisterRestClient based approach, as I am not in control of the JaxRS interface.

RestClientBuilder.newBuilder()
            .baseUri(URI.create("https://myexcelentserver"))
            .register(new BasicAuthentication("nonono", "badbad"))
            .sslContext(getSSLContext(certPath.orElse(null))) //Handling self-signed cert
            .build(ConfigurationService.class);

And the dependencies (Among others)

<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-jaxb</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-resteasy-jaxb</artifactId>
</dependency>
<dependency>
  <groupId>io.quarkus</groupId>
  <artifactId>quarkus-rest-client-jaxb</artifactId>
</dependency>

However i end up with the exception

javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/xml and type class eu.sos.cicso.configservice.api.model.agent.Agent

Thats not exactly the expected outcome, so I attempted the following instead

RestClientBuilder.newBuilder()
            .baseUri(URI.create("https://myexcelentserver"))
            .register(new BasicAuthentication("nonono", "badbad"))
             .register(new LoggingFilter())
             .register(new JAXBXmlRootElementProvider())
            .sslContext(getSSLContext(certPath.orElse(null)))
            .build(ConfigurationService.class);

Adding a logging filter and the org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlRootElementProvider. The error is now

org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException: RESTEASY006510: Could not find JAXBContextFinder for media type: application/xml

Through the logging filter I can see the output is valid XML as expected. I also used the ConfigurationService interface in a CXF proxy client out of pure deperation, and that worked without issue. I also tried (in another act of desperation) using the CXF JaxB provider but Quarkus did NOT seem to like all the extra dependencies that got pulled in and the application didn't even start.

So what am I doing wrong? It seems like I am misconfiguring something somewhere, but I am completely out of ideas as to what.

Martin Nielsen
  • 1,865
  • 6
  • 30
  • 54

1 Answers1

1

Well, in the end it turned out to be pretty obvious. It seems that the RestClientBuilder does very little, if anything at all, to autodiscover the classes in your classpath. I solved the problem by simply registering the missing class, which was luckily hiding in the same jar as the ElementProvider.

RestClientBuilder.newBuilder()
            .baseUri(URI.create(hostName))
             .register(new LoggingFilter())
             .register(new JAXBXmlRootElementProvider())
             .register(new XmlJAXBContextFinder())
            .build(ConfigurationService.class);
Martin Nielsen
  • 1,865
  • 6
  • 30
  • 54