Hi Romain,

On Thu, Jun 13, 2019 at 6:52 PM Romain Manni-Bucau <rmannibu...@gmail.com>
wrote:

>
> https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java#L1412
> is likely the one but looks like johnzon was not scanned nor registered
> programmatically
>
> Maybe code this bean:
>
> @Produces("application/json") // jaxrs import
> @Provider //jaxrs import
> @Dependent // cdi import
> public class MyJson<T> extends JsonbJaxrsProvider<T> {}
>
> Should be enough if it is the issue (or use delegation instead of
> inheritance)
>

Thanks for your help, I was able to make cxf work for me, and then package
it in a less error prone way ( https://github.com/rmaucher/tomcat-cxf ).
It does the following:
- Use a bean to add the json provider
- Package the necessary dependencies for json, jax-rs and cdi
- Bundle the web-fragment for the cxf cdi servlet (I wasted quite a lot of
time by using the regular cxf servlet, ultimately noticing that the trace
wasn't using cdi)
tomcat-owb should then be placed in lib, add the Server listener. It will
CDI enable all webapps (if they use the support). CXF then uses that
support. Due to its intricacies (and also the fact that it's not
lightweight), I don't think CXF is a good choice to put in the main Tomcat
lib folder (and at the moment, it won't work out of the box in that case).

I tested with a health bean from the "tck":
@Health
@ApplicationScoped
public class SuccessfulHealth implements HealthCheck {
    @Override
    public HealthCheckResponse call() {
        return HealthCheckResponse.named("successful-check").up().build();
    }
}
With the addition of the geronimo-health (which is a CDI extension),
geronimo-health-common, microprofile-health-api-1.0, and the fat jar
tomcat-cxf to /WEB-INF/lib, the bean is processed and runs (on
/rest/health). I expect the other mp APIs like metrics to work in a similar
way.

Rémy

Reply via email to