PS/FYI: just noticed jetty did the same kind of work with weld 4 years ago:
https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-cdi/cdi-servlet/src/main/config/etc/jetty-cdi.xml,
great Tomcat is catching up :).

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le lun. 17 juin 2019 à 10:52, Romain Manni-Bucau <rmannibu...@gmail.com> a
écrit :

> Hi Rémy,
>
> Great progression! Congrats!
>
> I have a few (details) notes - guess i'm opening an open door but just to
> ensure:
>
> 1. Is it intended to bind cxf to /rest/* in any case? I tend to see it
> bound on on /api but generally thanks to an Application
> (+ @ApplicationPath("api")) so cxf is bound on /*. Wonder if the listener
> shouldn't host that config and we would link it through a context listener
> or servletcontextinitializer (both will work and rely on tomcat internals)
> 2. In beans.xml, rather than annotated mode - which skips a lot of classes
> which can be used in CDI - we tend to prefer discovery mode "full" + trim:
> https://github.com/apache/geronimo-health/blob/master/geronimo-health/src/main/resources/META-INF/beans.xml
> 3. Why not merging SPI files thanks to maven?  (shade part, end of
> http://openwebbeans.apache.org/meecrowave/meecrowave-maven/index.html)
> 4. You have a spring config (cxf.xml), not sure it is intended?
> 5. jettison is not needed since it is not the one used for json
> serialization (guess you can drop several cxf deps)
>
> Hope it makes sense.
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
>
> Le lun. 17 juin 2019 à 10:29, Rémy Maucherat <r...@apache.org> a écrit :
>
>> 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