Hi Xavier,
The JAX-RS whiteboard works as a whiteboard, not an extender. In order to
register your extension service (the ExceptionMapper) with the whiteboard you
need to supply the correct service properties. In this case you need.
osgi.jaxrs.extension=true
If you’re using OSGi R7 declarative services (1.4) then there’s a component
property annotation you can use:
@JaxrsExtension
@Component
public class RestExceptionMapper implements
ExceptionMapper<RestCommonException> {
......
......
}
Another option (if you really want to use @Provider and not be an OSGi service)
is to create a JAX-RS Application containing the ExceptionMapper and advertise
that application to the whiteboard. You can then target the application with
your whiteboard resource using an extension select filter.
Best Regards,
Tim
Sent from my iPhone
> On 2 Apr 2019, at 09:42, Jean-Baptiste Onofré <[email protected]> wrote:
>
> Hi Xavier,
>
> As you have a RestExceptionMapper dealing with RestCommonException, you
> should have:
>
> @GET
> @Path("/foo")
> public String hello(String message) throws RestCommonException {
> ...
> }
>
> ?
>
> Regards
> JB
>
>> On 02/04/2019 10:27, xav wrote:
>> Hi all,
>>
>> I use https://github.com/apache/aries-jax-rs-whiteboard on karaf to provide
>> a REST API.
>> It's works but now I try to provide an ExceptionMapper with the annotation
>> @Provider
>>
>> @Provider
>> public class RestExceptionMapper implements
>> ExceptionMapper<RestCommonException> {
>>
>> ......
>> ......
>> }
>>
>> But unfortunately, my exception is not trap ????
>> In my main class, I write it like this:
>> @Component(
>> property = { "osgi.jaxrs.resource=true" },
>> service = SayHelloRestService.class, name = "SayHello", immediate =
>> true)
>> @Path(REST_PREFIX_RESSOURCE + "sayhello")
>> public class SayHelloRestService
>>
>>
>> Regards
>>
>>
>>
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>
>
> --
> Jean-Baptiste Onofré
> [email protected]
> http://blog.nanthrax.net
> Talend - http://www.talend.com