Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread xav
Hi Tim, Jb,

It's works,

Here the solution:

Extension
@Component(property = {"*osgi.jaxrs.extension=true*"})
@Produces(MediaType.APPLICATION_JSON)
public class RestExceptionMapper implements
ExceptionMapper {
..
..
}

Ressource

@Component(property = { "*osgi.jaxrs.resource=true*" },
service=SayHelloRestService.class, immediate = true)
@Produces(MediaType.APPLICATION_JSON)
@Path("sayhello")
public class SayHelloRestService {


}

The solution was, provides right property for ressources, and extension.

Thx for your links, and help.

Regards







--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread Tim Ward
I note that you’re using the Component Property annotations for the extension, 
but a raw property entry for the resource. If your build plugin is able to cope 
with Component Property annotations then you can use the @JaxrsResource 
annotation instead of a magic string. If your build plugin can’t process 
Component Property annotations then you will need to use the String form in 
both services. 

Tim

Sent from my iPhone

> On 2 Apr 2019, at 14:29, xav  wrote:
> 
> Hi tim,
> 
> I use JAXRS resource
> My RestExceptionMapper is coded like this
> 
> @JaxrsExtension
> @Component(service = RestExceptionMapper.class, name =
> "RestExceptionMapper", immediate = true)
> public class RestExceptionMapper implements
> ExceptionMapper
> 
> 
> 
> My ressources
> 
> @Component(
>property = { "osgi.jaxrs.resource=true" },
>service = SayHelloRestService.class, name = "SayHello", immediate =
> true)
> @Path("/sayhello")
> public class SayHelloRestService {
> 
> 
> @GET
> @Path("{name}")
> @Produces(MediaType.APPLICATION_JSON)
> public String sayHello(@PathParam("name") final String name) throws
> RestCommonException {
>Name namee = new Name (helloService.sayHello(name));
>throw new RestCommonException("pouet");
> }
> 
> And it's the same thing!!!
> 
> Thx for your help
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread xav
Hi tim,

I use JAXRS resource
My RestExceptionMapper is coded like this

@JaxrsExtension
@Component(service = RestExceptionMapper.class, name =
"RestExceptionMapper", immediate = true)
public class RestExceptionMapper implements
ExceptionMapper



My ressources

@Component(
property = { "osgi.jaxrs.resource=true" },
service = SayHelloRestService.class, name = "SayHello", immediate =
true)
@Path("/sayhello")
public class SayHelloRestService {


@GET
@Path("{name}")
@Produces(MediaType.APPLICATION_JSON)
public String sayHello(@PathParam("name") final String name) throws
RestCommonException {
Name namee = new Name (helloService.sayHello(name));
throw new RestCommonException("pouet");
}

And it's the same thing!!!

Thx for your help




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread Tim Ward
>> I don't know if, the aries withboard project (1.0.4) has implemented the
>> spec?

As Aries JAX-RS Whiteboard is the reference implementation I can say with 
reasonable confidence that it has implemented the specification. The issue is 
that the application code you have supplied isn’t using the JAX-RS whiteboard 
specification to provide the exception mapper. It doesn’t even appear to be 
registering the Exception Mapper as a service.

The JAX-RS Whiteboard specification does explain what to do here 

 and has an example here 
.
 Use of JAX-RS extensions is also covered in the MicroService tutorial at OSGi 
EnRoute 
.

You will note that all of these examples register the extension as a service 
and use the @JaxrsExtension annotation to add the necessary service properties.

Best Regards,

Tim

> On 2 Apr 2019, at 10:30, Jean-Baptiste Onofré  wrote:
> 
> Do you have a JAXRS Application containing the ExceptionMapper or are
> you using JAXRS resource ?
> 
> Regards
> JB
> 
> On 02/04/2019 11:28, xav wrote:
>> Hi JB,
>> 
>> Yes I did, but it's does not work!!
>> The Exception is throw in the console, and not trap to put my own http
>> response.
>> So ???
>> I don't know if, the aries withboard project (1.0.4) has implemented the
>> spec?
>> 
>> Thx
>> 
>> Xav
>> 
>> 
>> 
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>> 
> 
> -- 
> Jean-Baptiste Onofré
> jbono...@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com



Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread Jean-Baptiste Onofré
Do you have a JAXRS Application containing the ExceptionMapper or are
you using JAXRS resource ?

Regards
JB

On 02/04/2019 11:28, xav wrote:
> Hi JB,
> 
> Yes I did, but it's does not work!!
> The Exception is throw in the console, and not trap to put my own http
> response.
> So ???
> I don't know if, the aries withboard project (1.0.4) has implemented the
> spec?
> 
> Thx
> 
> Xav
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread xav
Hi JB,

Yes I did, but it's does not work!!
The Exception is throw in the console, and not trap to put my own http
response.
So ???
I don't know if, the aries withboard project (1.0.4) has implemented the
spec?

Thx

Xav



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread Tim Ward
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 {

..
..
}


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é  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 {
>> 
>> ..
>> ..
>> }
>> 
>> 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é
> jbono...@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com


Re: ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread Jean-Baptiste Onofré
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 {
> 
> ..
> ..
> }
> 
> 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é
jbono...@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com


ExceptionMapper on Aries JAX-RS Whiteboard on karaf 4.2.3 and above.

2019-04-02 Thread xav
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 {

..
..
}

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