You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by atouat <ad...@gmail.com> on 2018/09/05 14:18:28 UTC

Re: REST - Declarative Services

Hello to everybody,

I wanted to try out using Aries JAXRS Whiteboard, since there is released
version now.

For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
to install Aries Jaxrs Whiteboard.

The feature.xml looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
name="aries-jaxrs-whiteboard">
    <feature name="aries-jaxrs-whiteboard"
description="aries-jaxrs-whiteboard" version="1.0.0">
        <feature>http-whiteboard</feature>

<bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>

<bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>

<bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>

<bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
    </feature>
</features>

I have now all bundles active.

I tried the code example from @jbonofre (the giothub link returns an HTTP
404 error). My bundle was deplyoed and active, but I could not access my
rest service.

I tried to url http://loclahost:8181/myName but there was no response at
all.

What am I missing? Can someone provide a working example with Aris JAXRS
Whiteboard please?


Greetings,

Adnan



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

Re: REST - Declarative Services

Posted by Tim Ward <ti...@paremus.com>.

> On 5 Sep 2018, at 15:54, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> OK, it's what I knew ;)
> 
> So, basically, you answer helped the user generally speaking but I guess it's not exactly what the user expects.
> 

I was attempting to answer the question:

>>>> Can someone provide a working example with Aris JAXRS
>>>> Whiteboard please?


Other than the Aries JAX-RS whiteboard integration tests (which aren’t a gentle introduction!) enRoute has the only working examples I’m currently aware of. This is why I flagged it.
> Karaf has exactly the same target for the runtime space. Karaf Boot is more on the same space as enRoute.
> 
> I would be more than happy to help to support Karaf in enRoute, but it seems that Karaf doesn't have a lot of supporters "at" enRoute. I got comment from some enRoute guys saying that Karaf doesn't make sense and other blabla. That's why I didn't find the motivation to help ;)
> 
> Anyway, back on the user request, @Adnan I will add an example using Aries JAXRS in Karaf.
> 
> Thanks,
> Regards
> 
> On 05/09/2018 16:41, Tim Ward wrote:
>> OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 
>> 
>> The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.
>> 
>> If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!
>> 
>> Tim
>> 
>>> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>>> 
>>> Does it run in Karaf ?
>>> 
>>> Regards
>>> JB
>>> 
>>> On 05/09/2018 16:30, Tim Ward wrote:
>>>> OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.
>>>> 
>>>> https://enroute.osgi.org/Tutorial/ <https://enroute.osgi.org/Tutorial/>
>>>> 
>>>> Best Regards,
>>>> 
>>>> Tim
>>>> 
>>>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com <ma...@gmail.com>> wrote:
>>>>> 
>>>>> Hello to everybody,
>>>>> 
>>>>> I wanted to try out using Aries JAXRS Whiteboard, since there is released
>>>>> version now.
>>>>> 
>>>>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
>>>>> to install Aries Jaxrs Whiteboard.
>>>>> 
>>>>> The feature.xml looks like this:
>>>>> 
>>>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0 <http://karaf.apache.org/xmlns/features/v1.4.0>"
>>>>> name="aries-jaxrs-whiteboard">
>>>>>    <feature name="aries-jaxrs-whiteboard"
>>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>>>        <feature>http-whiteboard</feature>
>>>>> 
>>>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>>>    </feature>
>>>>> </features>
>>>>> 
>>>>> I have now all bundles active.
>>>>> 
>>>>> I tried the code example from @jbonofre (the giothub link returns an HTTP
>>>>> 404 error). My bundle was deplyoed and active, but I could not access my
>>>>> rest service.
>>>>> 
>>>>> I tried to url http://loclahost:8181/myName <http://loclahost:8181/myName> but there was no response at
>>>>> all.
>>>>> 
>>>>> What am I missing? Can someone provide a working example with Aris JAXRS
>>>>> Whiteboard please?
>>>>> 
>>>>> 
>>>>> Greetings,
>>>>> 
>>>>> Adnan
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html <http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html>
>>>> 
>>> 
>> 
> 


Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
OK, it's what I knew ;)

So, basically, you answer helped the user generally speaking but I guess 
it's not exactly what the user expects.

Karaf has exactly the same target for the runtime space. Karaf Boot is 
more on the same space as enRoute.

I would be more than happy to help to support Karaf in enRoute, but it 
seems that Karaf doesn't have a lot of supporters "at" enRoute. I got 
comment from some enRoute guys saying that Karaf doesn't make sense and 
other blabla. That's why I didn't find the motivation to help ;)

Anyway, back on the user request, @Adnan I will add an example using 
Aries JAXRS in Karaf.

Thanks,
Regards


On 05/09/2018 16:41, Tim Ward wrote:
> OSGi enRoute is a project aimed at getting users with little/no OSGi 
> experience familiar with OSGi specifications and best practices. It 
> produces bundles and repository indexes, but it is not itself a runtime.
>
> The project is deliberately not opinionated about server platforms, 
> and so it doesn’t use Karaf or any other platform. Instead it resolves 
> and assembles the bundles you need based on your application 
> requirements (using the standard OSGi resolver model and your build 
> dependencies). The output is a standalone executable JAR so that the 
> code can be easily run and debugged.
>
> If someone wanted to describe how to export a KAR/feature, or to add a 
> Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be 
> difficult, it is only Maven after all!
>
> Tim
>
>> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb@nanthrax.net 
>> <ma...@nanthrax.net>> wrote:
>>
>> Does it run in Karaf ?
>>
>> Regards
>> JB
>>
>>
>> On 05/09/2018 16:30, Tim Ward wrote:
>>> OSGi enRoute contains tutorials and examples which cover using the 
>>> JAX-RS whiteboard. They’re pretty quick to run through.
>>>
>>> https://enroute.osgi.org/Tutorial/
>>>
>>> Best Regards,
>>>
>>> Tim
>>>
>>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com 
>>>> <ma...@gmail.com>> wrote:
>>>>
>>>> Hello to everybody,
>>>>
>>>> I wanted to try out using Aries JAXRS Whiteboard, since there is 
>>>> released
>>>> version now.
>>>>
>>>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature 
>>>> in order
>>>> to install Aries Jaxrs Whiteboard.
>>>>
>>>> The feature.xml looks like this:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
>>>> name="aries-jaxrs-whiteboard">
>>>>    <feature name="aries-jaxrs-whiteboard"
>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>>        <feature>http-whiteboard</feature>
>>>>
>>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>>>
>>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>>>
>>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>>>
>>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 
>>>> <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>>    </feature>
>>>> </features>
>>>>
>>>> I have now all bundles active.
>>>>
>>>> I tried the code example from @jbonofre (the giothub link returns 
>>>> an HTTP
>>>> 404 error). My bundle was deplyoed and active, but I could not 
>>>> access my
>>>> rest service.
>>>>
>>>> I tried to url http://loclahost:8181/myName but there was no 
>>>> response at
>>>> all.
>>>>
>>>> What am I missing? Can someone provide a working example with Aris 
>>>> JAXRS
>>>> Whiteboard please?
>>>>
>>>>
>>>> Greetings,
>>>>
>>>> Adnan
>>>>
>>>>
>>>>
>>>> --
>>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>>
>>
>


Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Got it ;)

AFAIR, Christian started a PoC about a Karaf resolver. I will resume 
what he started.

Regards
JB


On 05/09/2018 17:01, Tim Ward wrote:
> I wasn’t referring to Karaf, I was referring to the enRoute build output!
>
> Tim
>
>> On 5 Sep 2018, at 16:00, Jean-Baptiste Onofré <jb@nanthrax.net 
>> <ma...@nanthrax.net>> wrote:
>>
>> By the way, Karaf is "not just Maven after all" ;) It's a little more 
>> than that ;) (actually largely more than that ;)).
>>
>>
>> On 05/09/2018 16:41, Tim Ward wrote:
>>> OSGi enRoute is a project aimed at getting users with little/no OSGi 
>>> experience familiar with OSGi specifications and best practices. It 
>>> produces bundles and repository indexes, but it is not itself a 
>>> runtime.
>>>
>>> The project is deliberately not opinionated about server platforms, 
>>> and so it doesn’t use Karaf or any other platform. Instead it 
>>> resolves and assembles the bundles you need based on your 
>>> application requirements (using the standard OSGi resolver model and 
>>> your build dependencies). The output is a standalone executable JAR 
>>> so that the code can be easily run and debugged.
>>>
>>> If someone wanted to describe how to export a KAR/feature, or to add 
>>> a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be 
>>> difficult, it is only Maven after all!
>>>
>>> Tim
>>>
>>>> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb@nanthrax.net 
>>>> <ma...@nanthrax.net>> wrote:
>>>>
>>>> Does it run in Karaf ?
>>>>
>>>> Regards
>>>> JB
>>>>
>>>>
>>>> On 05/09/2018 16:30, Tim Ward wrote:
>>>>> OSGi enRoute contains tutorials and examples which cover using the 
>>>>> JAX-RS whiteboard. They’re pretty quick to run through.
>>>>>
>>>>> https://enroute.osgi.org/Tutorial/
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Tim
>>>>>
>>>>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com 
>>>>>> <ma...@gmail.com>> wrote:
>>>>>>
>>>>>> Hello to everybody,
>>>>>>
>>>>>> I wanted to try out using Aries JAXRS Whiteboard, since there is 
>>>>>> released
>>>>>> version now.
>>>>>>
>>>>>> For this, I have donwloaded a new Karaf 4.2.1. I created a 
>>>>>> feature in order
>>>>>> to install Aries Jaxrs Whiteboard.
>>>>>>
>>>>>> The feature.xml looks like this:
>>>>>>
>>>>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>>>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
>>>>>> name="aries-jaxrs-whiteboard">
>>>>>>    <feature name="aries-jaxrs-whiteboard"
>>>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>>>>        <feature>http-whiteboard</feature>
>>>>>>
>>>>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>>>>>
>>>>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>>>>>
>>>>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>>>>>
>>>>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 
>>>>>> <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>>>>    </feature>
>>>>>> </features>
>>>>>>
>>>>>> I have now all bundles active.
>>>>>>
>>>>>> I tried the code example from @jbonofre (the giothub link returns 
>>>>>> an HTTP
>>>>>> 404 error). My bundle was deplyoed and active, but I could not 
>>>>>> access my
>>>>>> rest service.
>>>>>>
>>>>>> I tried to url http://loclahost:8181/myName but there was no 
>>>>>> response at
>>>>>> all.
>>>>>>
>>>>>> What am I missing? Can someone provide a working example with 
>>>>>> Aris JAXRS
>>>>>> Whiteboard please?
>>>>>>
>>>>>>
>>>>>> Greetings,
>>>>>>
>>>>>> Adnan
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>>>>
>>>>
>>>
>>
>


Re: REST - Declarative Services

Posted by Tim Ward <ti...@paremus.com>.
I wasn’t referring to Karaf, I was referring to the enRoute build output!

Tim

> On 5 Sep 2018, at 16:00, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> By the way, Karaf is "not just Maven after all" ;) It's a little more than that ;) (actually largely more than that ;)).
> 
> On 05/09/2018 16:41, Tim Ward wrote:
>> OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 
>> 
>> The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.
>> 
>> If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!
>> 
>> Tim
>> 
>>> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>>> 
>>> Does it run in Karaf ?
>>> 
>>> Regards
>>> JB
>>> 
>>> On 05/09/2018 16:30, Tim Ward wrote:
>>>> OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.
>>>> 
>>>> https://enroute.osgi.org/Tutorial/ <https://enroute.osgi.org/Tutorial/>
>>>> 
>>>> Best Regards,
>>>> 
>>>> Tim
>>>> 
>>>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com <ma...@gmail.com>> wrote:
>>>>> 
>>>>> Hello to everybody,
>>>>> 
>>>>> I wanted to try out using Aries JAXRS Whiteboard, since there is released
>>>>> version now.
>>>>> 
>>>>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
>>>>> to install Aries Jaxrs Whiteboard.
>>>>> 
>>>>> The feature.xml looks like this:
>>>>> 
>>>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0 <http://karaf.apache.org/xmlns/features/v1.4.0>"
>>>>> name="aries-jaxrs-whiteboard">
>>>>>    <feature name="aries-jaxrs-whiteboard"
>>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>>>        <feature>http-whiteboard</feature>
>>>>> 
>>>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>>>> 
>>>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>>>    </feature>
>>>>> </features>
>>>>> 
>>>>> I have now all bundles active.
>>>>> 
>>>>> I tried the code example from @jbonofre (the giothub link returns an HTTP
>>>>> 404 error). My bundle was deplyoed and active, but I could not access my
>>>>> rest service.
>>>>> 
>>>>> I tried to url http://loclahost:8181/myName <http://loclahost:8181/myName> but there was no response at
>>>>> all.
>>>>> 
>>>>> What am I missing? Can someone provide a working example with Aris JAXRS
>>>>> Whiteboard please?
>>>>> 
>>>>> 
>>>>> Greetings,
>>>>> 
>>>>> Adnan
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html <http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html>
>>>> 
>>> 
>> 
> 


Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
By the way, Karaf is "not just Maven after all" ;) It's a little more 
than that ;) (actually largely more than that ;)).


On 05/09/2018 16:41, Tim Ward wrote:
> OSGi enRoute is a project aimed at getting users with little/no OSGi 
> experience familiar with OSGi specifications and best practices. It 
> produces bundles and repository indexes, but it is not itself a runtime.
>
> The project is deliberately not opinionated about server platforms, 
> and so it doesn’t use Karaf or any other platform. Instead it resolves 
> and assembles the bundles you need based on your application 
> requirements (using the standard OSGi resolver model and your build 
> dependencies). The output is a standalone executable JAR so that the 
> code can be easily run and debugged.
>
> If someone wanted to describe how to export a KAR/feature, or to add a 
> Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be 
> difficult, it is only Maven after all!
>
> Tim
>
>> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb@nanthrax.net 
>> <ma...@nanthrax.net>> wrote:
>>
>> Does it run in Karaf ?
>>
>> Regards
>> JB
>>
>>
>> On 05/09/2018 16:30, Tim Ward wrote:
>>> OSGi enRoute contains tutorials and examples which cover using the 
>>> JAX-RS whiteboard. They’re pretty quick to run through.
>>>
>>> https://enroute.osgi.org/Tutorial/
>>>
>>> Best Regards,
>>>
>>> Tim
>>>
>>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com 
>>>> <ma...@gmail.com>> wrote:
>>>>
>>>> Hello to everybody,
>>>>
>>>> I wanted to try out using Aries JAXRS Whiteboard, since there is 
>>>> released
>>>> version now.
>>>>
>>>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature 
>>>> in order
>>>> to install Aries Jaxrs Whiteboard.
>>>>
>>>> The feature.xml looks like this:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
>>>> name="aries-jaxrs-whiteboard">
>>>>    <feature name="aries-jaxrs-whiteboard"
>>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>>        <feature>http-whiteboard</feature>
>>>>
>>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>>>
>>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>>>
>>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>>>
>>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 
>>>> <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>>    </feature>
>>>> </features>
>>>>
>>>> I have now all bundles active.
>>>>
>>>> I tried the code example from @jbonofre (the giothub link returns 
>>>> an HTTP
>>>> 404 error). My bundle was deplyoed and active, but I could not 
>>>> access my
>>>> rest service.
>>>>
>>>> I tried to url http://loclahost:8181/myName but there was no 
>>>> response at
>>>> all.
>>>>
>>>> What am I missing? Can someone provide a working example with Aris 
>>>> JAXRS
>>>> Whiteboard please?
>>>>
>>>>
>>>> Greetings,
>>>>
>>>> Adnan
>>>>
>>>>
>>>>
>>>> --
>>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>>
>>
>


Re: REST - Declarative Services

Posted by Tim Ward <ti...@paremus.com>.
OSGi enRoute is a project aimed at getting users with little/no OSGi experience familiar with OSGi specifications and best practices. It produces bundles and repository indexes, but it is not itself a runtime. 

The project is deliberately not opinionated about server platforms, and so it doesn’t use Karaf or any other platform. Instead it resolves and assembles the bundles you need based on your application requirements (using the standard OSGi resolver model and your build dependencies). The output is a standalone executable JAR so that the code can be easily run and debugged.

If someone wanted to describe how to export a KAR/feature, or to add a Karaf exporter to the bnd-export-maven-plugin then it shouldn’t be difficult, it is only Maven after all!

Tim

> On 5 Sep 2018, at 15:32, Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:
> 
> Does it run in Karaf ?
> 
> Regards
> JB
> 
> On 05/09/2018 16:30, Tim Ward wrote:
>> OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.
>> 
>> https://enroute.osgi.org/Tutorial/ <https://enroute.osgi.org/Tutorial/>
>> 
>> Best Regards,
>> 
>> Tim
>> 
>>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com <ma...@gmail.com>> wrote:
>>> 
>>> Hello to everybody,
>>> 
>>> I wanted to try out using Aries JAXRS Whiteboard, since there is released
>>> version now.
>>> 
>>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
>>> to install Aries Jaxrs Whiteboard.
>>> 
>>> The feature.xml looks like this:
>>> 
>>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0 <http://karaf.apache.org/xmlns/features/v1.4.0>"
>>> name="aries-jaxrs-whiteboard">
>>>    <feature name="aries-jaxrs-whiteboard"
>>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>>        <feature>http-whiteboard</feature>
>>> 
>>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>> 
>>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>> 
>>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>> 
>>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>>    </feature>
>>> </features>
>>> 
>>> I have now all bundles active.
>>> 
>>> I tried the code example from @jbonofre (the giothub link returns an HTTP
>>> 404 error). My bundle was deplyoed and active, but I could not access my
>>> rest service.
>>> 
>>> I tried to url http://loclahost:8181/myName <http://loclahost:8181/myName> but there was no response at
>>> all.
>>> 
>>> What am I missing? Can someone provide a working example with Aris JAXRS
>>> Whiteboard please?
>>> 
>>> 
>>> Greetings,
>>> 
>>> Adnan
>>> 
>>> 
>>> 
>>> --
>>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html <http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html>
>> 
> 


Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Does it run in Karaf ?

Regards
JB


On 05/09/2018 16:30, Tim Ward wrote:
> OSGi enRoute contains tutorials and examples which cover using the 
> JAX-RS whiteboard. They’re pretty quick to run through.
>
> https://enroute.osgi.org/Tutorial/
>
> Best Regards,
>
> Tim
>
>> On 5 Sep 2018, at 15:18, atouat <adnan.touati@gmail.com 
>> <ma...@gmail.com>> wrote:
>>
>> Hello to everybody,
>>
>> I wanted to try out using Aries JAXRS Whiteboard, since there is released
>> version now.
>>
>> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in 
>> order
>> to install Aries Jaxrs Whiteboard.
>>
>> The feature.xml looks like this:
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
>> name="aries-jaxrs-whiteboard">
>>    <feature name="aries-jaxrs-whiteboard"
>> description="aries-jaxrs-whiteboard" version="1.0.0">
>>        <feature>http-whiteboard</feature>
>>
>> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>>
>> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>>
>> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>>
>> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0 
>> <http://org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0></bundle>
>>    </feature>
>> </features>
>>
>> I have now all bundles active.
>>
>> I tried the code example from @jbonofre (the giothub link returns an HTTP
>> 404 error). My bundle was deplyoed and active, but I could not access my
>> rest service.
>>
>> I tried to url http://loclahost:8181/myName but there was no response at
>> all.
>>
>> What am I missing? Can someone provide a working example with Aris JAXRS
>> Whiteboard please?
>>
>>
>> Greetings,
>>
>> Adnan
>>
>>
>>
>> --
>> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>


Re: REST - Declarative Services

Posted by Tim Ward <ti...@paremus.com>.
OSGi enRoute contains tutorials and examples which cover using the JAX-RS whiteboard. They’re pretty quick to run through.

https://enroute.osgi.org/Tutorial/ <https://enroute.osgi.org/Tutorial/>

Best Regards,

Tim

> On 5 Sep 2018, at 15:18, atouat <ad...@gmail.com> wrote:
> 
> Hello to everybody,
> 
> I wanted to try out using Aries JAXRS Whiteboard, since there is released
> version now.
> 
> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
> to install Aries Jaxrs Whiteboard.
> 
> The feature.xml looks like this:
> 
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
> name="aries-jaxrs-whiteboard">
>    <feature name="aries-jaxrs-whiteboard"
> description="aries-jaxrs-whiteboard" version="1.0.0">
>        <feature>http-whiteboard</feature>
> 
> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
> 
> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
> 
> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>        <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>        <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>        <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>        <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
> 
> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
>    </feature>
> </features>
> 
> I have now all bundles active.
> 
> I tried the code example from @jbonofre (the giothub link returns an HTTP
> 404 error). My bundle was deplyoed and active, but I could not access my
> rest service.
> 
> I tried to url http://loclahost:8181/myName but there was no response at
> all.
> 
> What am I missing? Can someone provide a working example with Aris JAXRS
> Whiteboard please?
> 
> 
> Greetings,
> 
> Adnan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

As said, let me finish the Decanter 2.1.0 release and I will add a full
example.

Thanks !
Regards
JB

On 06/09/2018 11:54, atouat wrote:
> Good morning @jbonofre,thanks for your reply. I tried it, but unfortunately I
> got the same results.Here are the generated service.xmls:*1)
> RestApiApp*/<?xml version="1.0" encoding="UTF-8"?>              /*2)
> Api*<?xml version="1.0" encoding="UTF-8"?>/                /I can see the
> two services starting ( the sysouts are displayed int he karaf console).But
> the http:list and the cxf:list-endpoints command show an empty
> list.(Precisely, the http:list command shows only the CXFServletID  |
> Servlet             | Servlet-Name               | State       | Alias |
> Url----+---------------------+----------------------------+-------------+-------+---------113
> | CXFNonSpringServlet | cxf-osgi-transport-servlet | Deployed    | /cxf  |
> [/cxf/*])Calling the url http://localhost:8181/rest/object/getObject result
> in a 404 Not found@nicolas.brasey also calling the url 
> http://localhost:8181/cxf/rest/object/getObject result in a 404 Not foundI
> don't know what is missng :(Greetings, Adnan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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

Re: REST - Declarative Services

Posted by atouat <ad...@gmail.com>.
Good morning @jbonofre,thanks for your reply. I tried it, but unfortunately I
got the same results.Here are the generated service.xmls:*1)
RestApiApp*/<?xml version="1.0" encoding="UTF-8"?>              /*2)
Api*<?xml version="1.0" encoding="UTF-8"?>/                /I can see the
two services starting ( the sysouts are displayed int he karaf console).But
the http:list and the cxf:list-endpoints command show an empty
list.(Precisely, the http:list command shows only the CXFServletID  |
Servlet             | Servlet-Name               | State       | Alias |
Url----+---------------------+----------------------------+-------------+-------+---------113
| CXFNonSpringServlet | cxf-osgi-transport-servlet | Deployed    | /cxf  |
[/cxf/*])Calling the url http://localhost:8181/rest/object/getObject result
in a 404 Not found@nicolas.brasey also calling the url 
http://localhost:8181/cxf/rest/object/getObject result in a 404 Not foundI
don't know what is missng :(Greetings, Adnan



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

Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
I will add a full example to test this.

Thanks for your feedback.

Regards
JB

On 06/09/2018 10:49, Tim Ward wrote:
> Hi,
> 
> So there have been a number of suggestions on this thread which are
> unnecessary, and will confuse matters.
> 
>  1. There is no need to provide a JAX-RS Application to use the JAX-RS
>     whiteboard. The whiteboard always has a default application which
>     is, unsurprisingly, what is used by default.
>  2. The “osgi.jaxrs.endpoint” property is a service property of the
>     JaxrsServiceRuntime service. You can use it to work out what URI the
>     JAX-RS whiteboard is available on. It does absolutely nothing when
>     used as a property on your resource
>  3. The JAX_RS_APPLICATION_SELECT filter is not needed if you just want
>     to use the default application to host your resource.
> 
> 
> If you trim out the extra bits that have been added you should be back
> to a simple JAX-RS resource service that has the property
> “osgi.jaxrs.resource=true”. If you update to bnd 4.0 (the maven bundle
> plugin release was at the end of last week), then you can use the
> @JaxrsResource annotation to do this, otherwise you will need to keep
> using the String property name.
> 
> Verifying that the Aries JAX-RS whiteboard is working should be pretty
> simple. Once you have the bundle installed and running it will use the
> Http Whiteboard to register a Servlet. Once this is activated the
> whiteboard will register a JaxrsServiceRuntime service. If you look at
> the osgi.jaxrs.endpoint property of the JaxrsServiceRuntime service it
> will give you one or more URIs that you can use to reach the whiteboard.
> If you use a browser to connect to this URI you should get a welcome page.
> 
>   * If you don’t see a JaxrsServiceRuntime service then this indicates
>     that the whiteboard servlet it uses hasn’t been picked up. This
>     would be a problem with the Karaf web container.
>   * If the URI presented as a service property of the
>     JaxrsServiceRuntime service does not give you a welcome page then it
>     indicates that Karaf is doing some level of context root setting.
>     You will need to query the Karaf Http Whiteboard to work out what it
>     might have done
> 
> 
> Once you’ve validated that part it should be a case of
> installing/starting the bundle containing your resource, and navigating
> to it using the URI from before, plus the path of your resource method.
> 
> I hope this helps,
> 
> Best Regards,
> 
> Tim
> 
>> On 6 Sep 2018, at 06:56, Nicolas Brasey <nicolas.brasey@gmail.com
>> <ma...@gmail.com>> wrote:
>>
>> Hi,
>>
>> Are you sure you are not missing the "cxf" prefix in the URL to access
>> your endpoint? By default, cxf deploys your endpoint with the
>> CXFNonSpringServlet, which listens on the cxf context path, so your
>> endpoint should be available here:
>>
>> http://localhost:8181/cxf/hello <http://localhost:8181/hello>
>>
>> my 2 cents...
>>
>> Nicolas
>>
>>
>>
>>
>>
>> On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> wrote:
>>
>>     Hi,
>>
>>     did you try to add a application with your context.
>>
>>     Something like:
>>
>>     @Component(
>>                     service = Application.class,
>>                     property= {
>>                                     "osgi.jaxrs.name
>>     <http://osgi.jaxrs.name/>=RestApp",
>>                                     JAX_RS_APPLICATION_BASE +
>>     "=/rest",     
>>                                     "authentication.with=keycloak"
>>                     }
>>             )
>>     public class RestApiApp extends Application{
>>
>>             @Override
>>       public Set<Object> getSingletons() {
>>           return Collections.singleton(this);
>>       }
>>     }
>>
>>     The resource can refer this application:
>>
>>     @Component(
>>             service = Api.class,
>>             property = {
>>                             "osgi.jaxrs.name
>>     <http://osgi.jaxrs.name/>=RestApi",
>>                             "osgi.jaxrs.resource=true",
>>                            
>>     "osgi.jaxrs.application.select=(osgi.jaxrs.name
>>     <http://osgi.jaxrs.name/>=RestApp)"
>>             }
>>     )
>>     @Path("/object")
>>     public final class Api {
>>             public static final Response EMPTY_RESPONSE =
>>     Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
>>             @GET
>>             @Path("/getObject")
>>             @Produces(MediaType.APPLICATION_JSON)
>>             public String getObject() {
>>                 //return some json
>>             }
>>     }
>>
>>     Regards
>>     JB
>>
>>     On 05/09/2018 22:38, atouat wrote:
>>     > Hi Francois,
>>     >
>>     > I treid that too. See this excerpt:
>>     >
>>     > karaf@root()> service:list | grep -C 10 rest
>>     > [de.rest.test.ExampleRest]
>>     > --------------------------
>>     >  component.id <http://component.id/> = 4
>>     >  component.name <http://component.name/> = de.rest.test.ExampleRest
>>     >  osgi.jaxrs.application.select = (osgi.jaxrs.name
>>     <http://osgi.jaxrs.name/>=.default)
>>     > * osgi.jaxrs.endpoint = /hello*
>>     > osgi.jaxrs.resource = true
>>     >  service.bundleid = 102
>>     >  service.id <http://service.id/> = 139
>>     >  service.scope = bundle
>>     > Provided by :
>>     >  de.rest.test.whiteboard.ds Bundle (102)
>>     >
>>     >
>>     > But when calling http://localhost:8181/hello, I get a 404 not
>>     found error.
>>     >
>>     >
>>     > Thansk for your input :)
>>     >
>>     >
>>     > Greetings,
>>     >
>>     > Adnan
>>     >
>>     >
>>     >
>>     > --
>>     > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>>     >
>>
>>     -- 
>>     Jean-Baptiste Onofré
>>     jbonofre@apache.org <ma...@apache.org>
>>     http://blog.nanthrax.net <http://blog.nanthrax.net/>
>>     Talend - http://www.talend.com <http://www.talend.com/>
>>
> 

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

Re: REST - Declarative Services

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

There is an issue on the Apache Aries JAX-RS Whiteboard component, may
be it's related to your problem :

https://issues.apache.org/jira/browse/ARIES-1825

regards,

François Papon
fpapon@apache.org

Le 06/09/2018 à 14:09, atouat a écrit :
> Hi @Tim-Ward-2,
>
> thatns for your input. I cleaned my karaf and just installed my feature xml.
> Aöll Bunldes are active.
>
> karaf@root()> list
> START LEVEL 100 , List Threshold: 50
>  ID | State  | Lvl | Version            | Name
> ----+--------+-----+--------------------+---------------------------------------------------------------------
>  23 | Active |  80 | 4.2.1              | Apache Karaf :: OSGi Services ::
> Event
>  45 | Active |  80 | 0.0.0              | aries-jaxrs-whiteboard.xml
>  49 | Active |  80 | 1.0.0              | Apache Aries JAX-RS Specification
> API
>  50 | Active |  80 | 1.0.0              | Apache Aries JAX-RS Whiteboard
>  52 | Active |  80 | 1.1.2              | Apache Felix Servlet API
>  59 | Active |  80 | 1.3.0.1            | Apache ServiceMix :: Specs ::
> Annotation API 1.3
>  60 | Active |  80 | 4.6.0              | Apache XBean OSGI Bundle Utilities
>  61 | Active |  80 | 4.6.0              | Apache XBean :: Classpath Resource
> Finder
>  89 | Active |  80 | 6.2.0              | org.objectweb.asm
>  90 | Active |  80 | 6.2.0              | org.objectweb.asm.commons
>  91 | Active |  80 | 6.2.0              | org.objectweb.asm.tree
>  98 | Active |  80 | 1.1.0.201802012106 |
> org.osgi:org.osgi.service.http.whiteboard
>  99 | Active |  80 | 1.0.0.201802012106 | org.osgi:org.osgi.service.jaxrs
> 100 | Active |  80 | 1.1.0.201802012106 | org.osgi:org.osgi.util.function
> 101 | Active |  80 | 1.1.0.201802012106 | org.osgi:org.osgi.util.promise
>
> This is what I found about the JaxrsServiceRuntime:
>
>
> karaf@root()> service:list JaxrsServiceRuntime
> [org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime]
> ----------------------------------------------------
>  service.bundleid = 50
>  service.id = 115
>  service.pid = org.apache.aries.jax.rs.whiteboard.default
>  service.ranking = -2147483648
>  service.scope = singleton
> Provided by :
>  Apache Aries JAX-RS Whiteboard (50)
>
>
> The JaxrsServiceRuntime is rgeistered as a service, so far so good. But I
> dont's see a osgi.jaxrs.endpoint  service property. 
>
> @jbonofre do you have an idea what is missing within the karaf context?
>
> Greetings,
>
>
> Adnan
>
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: REST - Declarative Services

Posted by atouat <ad...@gmail.com>.
Hi @Tim-Ward-2,

thatns for your input. I cleaned my karaf and just installed my feature xml.
Aöll Bunldes are active.

karaf@root()> list
START LEVEL 100 , List Threshold: 50
 ID | State  | Lvl | Version            | Name
----+--------+-----+--------------------+---------------------------------------------------------------------
 23 | Active |  80 | 4.2.1              | Apache Karaf :: OSGi Services ::
Event
 45 | Active |  80 | 0.0.0              | aries-jaxrs-whiteboard.xml
 49 | Active |  80 | 1.0.0              | Apache Aries JAX-RS Specification
API
 50 | Active |  80 | 1.0.0              | Apache Aries JAX-RS Whiteboard
 52 | Active |  80 | 1.1.2              | Apache Felix Servlet API
 59 | Active |  80 | 1.3.0.1            | Apache ServiceMix :: Specs ::
Annotation API 1.3
 60 | Active |  80 | 4.6.0              | Apache XBean OSGI Bundle Utilities
 61 | Active |  80 | 4.6.0              | Apache XBean :: Classpath Resource
Finder
 89 | Active |  80 | 6.2.0              | org.objectweb.asm
 90 | Active |  80 | 6.2.0              | org.objectweb.asm.commons
 91 | Active |  80 | 6.2.0              | org.objectweb.asm.tree
 98 | Active |  80 | 1.1.0.201802012106 |
org.osgi:org.osgi.service.http.whiteboard
 99 | Active |  80 | 1.0.0.201802012106 | org.osgi:org.osgi.service.jaxrs
100 | Active |  80 | 1.1.0.201802012106 | org.osgi:org.osgi.util.function
101 | Active |  80 | 1.1.0.201802012106 | org.osgi:org.osgi.util.promise

This is what I found about the JaxrsServiceRuntime:


karaf@root()> service:list JaxrsServiceRuntime
[org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime]
----------------------------------------------------
 service.bundleid = 50
 service.id = 115
 service.pid = org.apache.aries.jax.rs.whiteboard.default
 service.ranking = -2147483648
 service.scope = singleton
Provided by :
 Apache Aries JAX-RS Whiteboard (50)


The JaxrsServiceRuntime is rgeistered as a service, so far so good. But I
dont's see a osgi.jaxrs.endpoint  service property. 

@jbonofre do you have an idea what is missing within the karaf context?

Greetings,


Adnan






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

Re: REST - Declarative Services

Posted by Tim Ward <ti...@paremus.com>.
Hi,

So there have been a number of suggestions on this thread which are unnecessary, and will confuse matters.

There is no need to provide a JAX-RS Application to use the JAX-RS whiteboard. The whiteboard always has a default application which is, unsurprisingly, what is used by default.
The “osgi.jaxrs.endpoint” property is a service property of the JaxrsServiceRuntime service. You can use it to work out what URI the JAX-RS whiteboard is available on. It does absolutely nothing when used as a property on your resource
The JAX_RS_APPLICATION_SELECT filter is not needed if you just want to use the default application to host your resource.

If you trim out the extra bits that have been added you should be back to a simple JAX-RS resource service that has the property “osgi.jaxrs.resource=true”. If you update to bnd 4.0 (the maven bundle plugin release was at the end of last week), then you can use the @JaxrsResource annotation to do this, otherwise you will need to keep using the String property name.

Verifying that the Aries JAX-RS whiteboard is working should be pretty simple. Once you have the bundle installed and running it will use the Http Whiteboard to register a Servlet. Once this is activated the whiteboard will register a JaxrsServiceRuntime service. If you look at the osgi.jaxrs.endpoint property of the JaxrsServiceRuntime service it will give you one or more URIs that you can use to reach the whiteboard. If you use a browser to connect to this URI you should get a welcome page.

If you don’t see a JaxrsServiceRuntime service then this indicates that the whiteboard servlet it uses hasn’t been picked up. This would be a problem with the Karaf web container.
If the URI presented as a service property of the JaxrsServiceRuntime service does not give you a welcome page then it indicates that Karaf is doing some level of context root setting. You will need to query the Karaf Http Whiteboard to work out what it might have done

Once you’ve validated that part it should be a case of installing/starting the bundle containing your resource, and navigating to it using the URI from before, plus the path of your resource method.

I hope this helps,

Best Regards,

Tim

> On 6 Sep 2018, at 06:56, Nicolas Brasey <ni...@gmail.com> wrote:
> 
> Hi,
> 
> Are you sure you are not missing the "cxf" prefix in the URL to access your endpoint? By default, cxf deploys your endpoint with the CXFNonSpringServlet, which listens on the cxf context path, so your endpoint should be available here:
> 
> http://localhost:8181/cxf/hello <http://localhost:8181/hello>
> 
> my 2 cents...
> 
> Nicolas
> 
> 
> 
> 
> 
> On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
> Hi,
> 
> did you try to add a application with your context.
> 
> Something like:
> 
> @Component(
>                 service = Application.class,
>                 property= {
>                                 "osgi.jaxrs.name <http://osgi.jaxrs.name/>=RestApp",
>                                 JAX_RS_APPLICATION_BASE + "=/rest",     
>                                 "authentication.with=keycloak"
>                 }
>         )
> public class RestApiApp extends Application{
> 
>         @Override
>   public Set<Object> getSingletons() {
>       return Collections.singleton(this);
>   }
> }
> 
> The resource can refer this application:
> 
> @Component(
>         service = Api.class,
>         property = {
>                         "osgi.jaxrs.name <http://osgi.jaxrs.name/>=RestApi",
>                         "osgi.jaxrs.resource=true",
>                         "osgi.jaxrs.application.select=(osgi.jaxrs.name <http://osgi.jaxrs.name/>=RestApp)"
>         }
> )
> @Path("/object")
> public final class Api {
>         public static final Response EMPTY_RESPONSE =
> Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
>         @GET
>         @Path("/getObject")
>         @Produces(MediaType.APPLICATION_JSON)
>         public String getObject() {
>             //return some json
>         }
> }
> 
> Regards
> JB
> 
> On 05/09/2018 22:38, atouat wrote:
> > Hi Francois,
> > 
> > I treid that too. See this excerpt:
> > 
> > karaf@root()> service:list | grep -C 10 rest
> > [de.rest.test.ExampleRest]
> > --------------------------
> >  component.id <http://component.id/> = 4
> >  component.name <http://component.name/> = de.rest.test.ExampleRest
> >  osgi.jaxrs.application.select = (osgi.jaxrs.name <http://osgi.jaxrs.name/>=.default)
> > * osgi.jaxrs.endpoint = /hello* 
> > osgi.jaxrs.resource = true
> >  service.bundleid = 102
> >  service.id <http://service.id/> = 139
> >  service.scope = bundle
> > Provided by : 
> >  de.rest.test.whiteboard.ds Bundle (102)
> > 
> > 
> > But when calling http://localhost:8181/hello <http://localhost:8181/hello>, I get a 404 not found error.
> > 
> > 
> > Thansk for your input :)
> > 
> > 
> > Greetings,
> > 
> > Adnan
> > 
> > 
> > 
> > --
> > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html <http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html>
> > 
> 
> -- 
> Jean-Baptiste Onofré
> jbonofre@apache.org <ma...@apache.org>
> http://blog.nanthrax.net <http://blog.nanthrax.net/>
> Talend - http://www.talend.com <http://www.talend.com/>


Re: REST - Declarative Services

Posted by Nicolas Brasey <ni...@gmail.com>.
Hi,

Are you sure you are not missing the "cxf" prefix in the URL to access your
endpoint? By default, cxf deploys your endpoint with the
CXFNonSpringServlet, which listens on the cxf context path, so your
endpoint should be available here:

http://localhost:8181/cxf/hello <http://localhost:8181/hello>

my 2 cents...

Nicolas





On Thu, Sep 6, 2018 at 5:58 AM Jean-Baptiste Onofré <jb...@nanthrax.net> wrote:

> Hi,
>
> did you try to add a application with your context.
>
> Something like:
>
> @Component(
>                 service = Application.class,
>                 property= {
>                                 "osgi.jaxrs.name=RestApp",
>                                 JAX_RS_APPLICATION_BASE + "=/rest",
>                                 "authentication.with=keycloak"
>                 }
>         )
> public class RestApiApp extends Application{
>
>         @Override
>   public Set<Object> getSingletons() {
>       return Collections.singleton(this);
>   }
> }
>
> The resource can refer this application:
>
> @Component(
>         service = Api.class,
>         property = {
>                         "osgi.jaxrs.name=RestApi",
>                         "osgi.jaxrs.resource=true",
>                         "osgi.jaxrs.application.select=(osgi.jaxrs.name
> =RestApp)"
>         }
> )
> @Path("/object")
> public final class Api {
>         public static final Response EMPTY_RESPONSE =
> Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
>         @GET
>         @Path("/getObject")
>         @Produces(MediaType.APPLICATION_JSON)
>         public String getObject() {
>             //return some json
>         }
> }
>
> Regards
> JB
>
> On 05/09/2018 22:38, atouat wrote:
> > Hi Francois,
> >
> > I treid that too. See this excerpt:
> >
> > karaf@root()> service:list | grep -C 10 rest
> > [de.rest.test.ExampleRest]
> > --------------------------
> >  component.id = 4
> >  component.name = de.rest.test.ExampleRest
> >  osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
> > * osgi.jaxrs.endpoint = /hello*
> > osgi.jaxrs.resource = true
> >  service.bundleid = 102
> >  service.id = 139
> >  service.scope = bundle
> > Provided by :
> >  de.rest.test.whiteboard.ds Bundle (102)
> >
> >
> > But when calling http://localhost:8181/hello, I get a 404 not found
> error.
> >
> >
> > Thansk for your input :)
> >
> >
> > Greetings,
> >
> > Adnan
> >
> >
> >
> > --
> > Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> >
>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

did you try to add a application with your context.

Something like:

@Component(
		service = Application.class,
		property= {
				"osgi.jaxrs.name=RestApp",
				JAX_RS_APPLICATION_BASE + "=/rest",	
				"authentication.with=keycloak"
		}
	)
public class RestApiApp extends Application{

	@Override
  public Set<Object> getSingletons() {
      return Collections.singleton(this);
  }
}

The resource can refer this application:

@Component(
	service = Api.class,
	property = {
			"osgi.jaxrs.name=RestApi",
			"osgi.jaxrs.resource=true",
			"osgi.jaxrs.application.select=(osgi.jaxrs.name=RestApp)"
	}
)
@Path("/object")
public final class Api {
	public static final Response EMPTY_RESPONSE =
Response.noContent().type(MediaType.TEXT_HTML_TYPE).build();
	@GET
	@Path("/getObject")
	@Produces(MediaType.APPLICATION_JSON)
	public String getObject() {
	    //return some json
	}
}

Regards
JB

On 05/09/2018 22:38, atouat wrote:
> Hi Francois,
> 
> I treid that too. See this excerpt:
> 
> karaf@root()> service:list | grep -C 10 rest
> [de.rest.test.ExampleRest]
> --------------------------
>  component.id = 4
>  component.name = de.rest.test.ExampleRest
>  osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
> * osgi.jaxrs.endpoint = /hello* 
> osgi.jaxrs.resource = true
>  service.bundleid = 102
>  service.id = 139
>  service.scope = bundle
> Provided by : 
>  de.rest.test.whiteboard.ds Bundle (102)
> 
> 
> But when calling http://localhost:8181/hello, I get a 404 not found error.
> 
> 
> Thansk for your input :)
> 
> 
> Greetings,
> 
> Adnan
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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

Re: REST - Declarative Services

Posted by atouat <ad...@gmail.com>.
Hi Francois,

I treid that too. See this excerpt:

karaf@root()> service:list | grep -C 10 rest
[de.rest.test.ExampleRest]
--------------------------
 component.id = 4
 component.name = de.rest.test.ExampleRest
 osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
* osgi.jaxrs.endpoint = /hello* 
osgi.jaxrs.resource = true
 service.bundleid = 102
 service.id = 139
 service.scope = bundle
Provided by : 
 de.rest.test.whiteboard.ds Bundle (102)


But when calling http://localhost:8181/hello, I get a 404 not found error.


Thansk for your input :)


Greetings,

Adnan



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

Re: REST - Declarative Services

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

May be you are missing the JAX_RS_SERVICE_ENDPOINT, there is a
description in the specification :

https://osgi.org/specification/osgi.cmpn/7.0.0/service.jaxrs.html#org.osgi.service.jaxrs.runtime.JaxrsServiceRuntimeConstants.JAX_RS_SERVICE_ENDPOINT

regards,

François Papon
fpapon@apache.org

Le 05/09/2018 à 22:47, atouat a écrit :
> Hi @all,
>
> Wow! Very active community here in the forum. I appreciate this, thanks.
>
> @jbonofre In a current project at work, we already have rest services
> running in karaf by using cxf and blueprint.
> I also tried out @cschneider's propositon wiht cxf-dosgi and I got that
> running too.
>
> I just wanted to try out publishing rest services via whiteboard, and since
> aries jax rs whiteboard is the reference implementation I took that.
>
> About your example. My code looks like this:
>
> /import org.osgi.service.component.annotations.Activate;
> import org.osgi.service.component.annotations.Component;
> import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;
>
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.PathParam;
>
>
> @Component(
>         immediate = true,
>         property = {
>                 JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT +
> "=(osgi.jaxrs.name=.default)",
>                 JaxrsWhiteboardConstants.JAX_RS_RESOURCE + "=true"
>         },
>         service = ExampleRest.class
> )
> public class ExampleRest {
>
>     @Activate
>     public void onActivate(){
>         System.out.println("ExampleRest activating!");
>     }
>
>     @GET
>     @Path("/{name}")
>     public String sayHello(@PathParam("name") String name) {
>         return "Hello " + name;
>     }
>
> }/
>
> The generated service.component.xml under OSGI-INF looks like this:
>
> /<?xml version="1.0" encoding="UTF-8"?>
> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
> name="de.rest.test.ExampleRest" immediate="true" activate="onActivate">
>   <implementation class="de.rest.test.ExampleRest"/>
>   <service>
>     <provide interface="de.rest.test.ExampleRest"/>
>   </service>
>   <property name="osgi.jaxrs.application.select" type="String"
> value="(osgi.jaxrs.name=.default)"/>
>   <property name="osgi.jaxrs.resource" type="String" value="true"/>
> </scr:component>/
>
>
> And the generated Manifest like this:
>
> /Manifest-Version: 1.0
> Bnd-LastModified: 1536171585428
> Build-Jdk: 1.8.0_171
> Built-By: adnan
> Bundle-Description: de.rest.test.whiteboard.ds OSGi bundle project.
> Bundle-ManifestVersion: 2
> Bundle-Name: de.rest.test.whiteboard.ds Bundle
> Bundle-SymbolicName: de.rest.test.whiteboard.ds
> Bundle-Version: 1.0.0.SNAPSHOT
> Created-By: Apache Maven Bundle Plugin
> Export-Package: de.rest.test;version="1.0.0.SNAPSHOT";uses:="javax.ws.
>  rs"
> Import-Package: javax.ws.rs;version="[2.1,3)"
> Provide-Capability: osgi.service;objectClass:List<String>="de.rest.tes
>  t.ExampleRest"
> Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
>  nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.ee;filter:="(&(osgi.e
>  e=JavaSE)(version=1.8))"
> Service-Component: OSGI-INF/de.rest.test.ExampleRest.xml
> Tool: Bnd-3.5.0.201709291849/
>
> I also already had a look at the osgienroute example @Tim-Ward-2 mentioned.
> I created the rest bundle based on the osgi enroute maven archetype. The
> code looks very similar (The following is the code generated by the enroute
> archetype):
>
> /import javax.ws.rs.GET;
> import javax.ws.rs.Path;
>
> import org.osgi.service.component.annotations.Component;
> import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;
>
> @Component(service=RestComponentImpl.class)
> @JaxrsResource
> public class RestComponentImpl {
>     
>     //TODO add an implementation
>     
>     @Path("rest")
>     @GET
>     public String toUpper() {
>         return "Hello World!";
>     }
> }
> /
>
> I couldnt get a well generetaed manifest by the bnd-tool, so I used the
> maven-bundle.-plugin and the generetd service.component.xml and the genrated
> Manifest look similar too.
>
>
> After installing the feature as mentioned in my previous post and deploying
> the bundle with you corde examples @jbonofre 
>  (bundle symbolic name is de.rest.test.whiteboard.ds Bundle)  and also the
> enroute exmaple bunlde (bundly symbolic name is rest-enroute), I have the
> following in karaf:
>
> /
> karaf@root()> list                                                                                                                                       
> START LEVEL 100 , List Threshold: 50
>  ID │ State  │ Lvl │ Version            │ Name
> ────┼────────┼─────┼────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
>  23 │ Active │  80 │ 4.2.1              │ Apache Karaf :: OSGi Services ::
> Event
>  45 │ Active │  80 │ 0.0.0              │ aries-jaxrs-whiteboard.xml
>  49 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Specification
> API
>  50 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Whiteboard
>  52 │ Active │  80 │ 1.1.2              │ Apache Felix Servlet API
>  59 │ Active │  80 │ 1.3.0.1            │ Apache ServiceMix :: Specs ::
> Annotation API 1.3
>  60 │ Active │  80 │ 4.6.0              │ Apache XBean OSGI Bundle Utilities
>  61 │ Active │  80 │ 4.6.0              │ Apache XBean :: Classpath Resource
> Finder
>  89 │ Active │  80 │ 6.2.0              │ org.objectweb.asm
>  90 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.commons
>  91 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.tree
>  98 │ Active │  80 │ 1.1.0.201802012106 │
> org.osgi:org.osgi.service.http.whiteboard
>  99 │ Active │  80 │ 1.0.0.201802012106 │ org.osgi:org.osgi.service.jaxrs
> 100 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.function
> 101 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.promise
> 102 │ Active │  80 │ 1.0.0.SNAPSHOT     │ de.rest.test.whiteboard.ds Bundle
> 103 │ Active │  80 │ 1.0.0.SNAPSHOT     │ rest-enroute
> karaf@root()> /
>
>
> With the command karaf@root()> service:list , I get (excerpt) :
>
> /karaf@root()> service:list                                                                                              
> [de.rest.test.ExampleRest]
> --------------------------
>  component.id = 2
>  component.name = de.rest.test.ExampleRest
>  osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
>  osgi.jaxrs.resource = true
>  service.bundleid = 102
>  service.id = 123
>  service.scope = bundle
> Provided by : 
>  de.rest.test.whiteboard.ds Bundle (102)
>
> [val.rest.enroute.RestComponentImpl]
> ------------------------------------
>  component.id = 3
>  component.name = val.rest.enroute.RestComponentImpl
>  service.bundleid = 103
>  service.id = 124
>  service.scope = bundle
> Provided by : 
>  rest-enroute (103)/
>
> With the command karaf@root()> http:list , I get :
>
> /karaf@root()> http:list
> ID │ Servlet │ Servlet-Name │ State │ Alias │ Url
> ───┼─────────┼──────────────┼───────┼───────┼────
> karaf@root()>  /
>
> Yes, nothing. So no servlet or something in that regard is registered. It
> can not work, right? 
>
> When I install the feature cxf-jaxrs I get this:
>
> /karaf@root(feature)> http:list
> ID  │ Servlet             │ Servlet-Name               │ State       │ Alias
> │ Url
> ────┼─────────────────────┼────────────────────────────┼─────────────┼───────┼─────────
> 114 │ CXFNonSpringServlet │ cxf-osgi-transport-servlet │ Deployed    │ /cxf 
> │ [/cxf/*]
> karaf@root(feature)/
>
>
> I assume I am missing something obvious and substantial. Can someone point
> me to what I am missing?
>
> Thanks in advance!
>
>
> Greetings,
>
> Adnan
>
>
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: REST - Declarative Services

Posted by atouat <ad...@gmail.com>.
Hi @all,

Wow! Very active community here in the forum. I appreciate this, thanks.

@jbonofre In a current project at work, we already have rest services
running in karaf by using cxf and blueprint.
I also tried out @cschneider's propositon wiht cxf-dosgi and I got that
running too.

I just wanted to try out publishing rest services via whiteboard, and since
aries jax rs whiteboard is the reference implementation I took that.

About your example. My code looks like this:

/import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;


@Component(
        immediate = true,
        property = {
                JaxrsWhiteboardConstants.JAX_RS_APPLICATION_SELECT +
"=(osgi.jaxrs.name=.default)",
                JaxrsWhiteboardConstants.JAX_RS_RESOURCE + "=true"
        },
        service = ExampleRest.class
)
public class ExampleRest {

    @Activate
    public void onActivate(){
        System.out.println("ExampleRest activating!");
    }

    @GET
    @Path("/{name}")
    public String sayHello(@PathParam("name") String name) {
        return "Hello " + name;
    }

}/

The generated service.component.xml under OSGI-INF looks like this:

/<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
name="de.rest.test.ExampleRest" immediate="true" activate="onActivate">
  <implementation class="de.rest.test.ExampleRest"/>
  <service>
    <provide interface="de.rest.test.ExampleRest"/>
  </service>
  <property name="osgi.jaxrs.application.select" type="String"
value="(osgi.jaxrs.name=.default)"/>
  <property name="osgi.jaxrs.resource" type="String" value="true"/>
</scr:component>/


And the generated Manifest like this:

/Manifest-Version: 1.0
Bnd-LastModified: 1536171585428
Build-Jdk: 1.8.0_171
Built-By: adnan
Bundle-Description: de.rest.test.whiteboard.ds OSGi bundle project.
Bundle-ManifestVersion: 2
Bundle-Name: de.rest.test.whiteboard.ds Bundle
Bundle-SymbolicName: de.rest.test.whiteboard.ds
Bundle-Version: 1.0.0.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: de.rest.test;version="1.0.0.SNAPSHOT";uses:="javax.ws.
 rs"
Import-Package: javax.ws.rs;version="[2.1,3)"
Provide-Capability: osgi.service;objectClass:List<String>="de.rest.tes
 t.ExampleRest"
Require-Capability: osgi.extender;filter:="(&(osgi.extender=osgi.compo
 nent)(version>=1.3.0)(!(version>=2.0.0)))",osgi.ee;filter:="(&(osgi.e
 e=JavaSE)(version=1.8))"
Service-Component: OSGI-INF/de.rest.test.ExampleRest.xml
Tool: Bnd-3.5.0.201709291849/

I also already had a look at the osgienroute example @Tim-Ward-2 mentioned.
I created the rest bundle based on the osgi enroute maven archetype. The
code looks very similar (The following is the code generated by the enroute
archetype):

/import javax.ws.rs.GET;
import javax.ws.rs.Path;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;

@Component(service=RestComponentImpl.class)
@JaxrsResource
public class RestComponentImpl {
    
    //TODO add an implementation
    
    @Path("rest")
    @GET
    public String toUpper() {
        return "Hello World!";
    }
}
/

I couldnt get a well generetaed manifest by the bnd-tool, so I used the
maven-bundle.-plugin and the generetd service.component.xml and the genrated
Manifest look similar too.


After installing the feature as mentioned in my previous post and deploying
the bundle with you corde examples @jbonofre 
 (bundle symbolic name is de.rest.test.whiteboard.ds Bundle)  and also the
enroute exmaple bunlde (bundly symbolic name is rest-enroute), I have the
following in karaf:

/
karaf@root()> list                                                                                                                                       
START LEVEL 100 , List Threshold: 50
 ID │ State  │ Lvl │ Version            │ Name
────┼────────┼─────┼────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────
 23 │ Active │  80 │ 4.2.1              │ Apache Karaf :: OSGi Services ::
Event
 45 │ Active │  80 │ 0.0.0              │ aries-jaxrs-whiteboard.xml
 49 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Specification
API
 50 │ Active │  80 │ 1.0.0              │ Apache Aries JAX-RS Whiteboard
 52 │ Active │  80 │ 1.1.2              │ Apache Felix Servlet API
 59 │ Active │  80 │ 1.3.0.1            │ Apache ServiceMix :: Specs ::
Annotation API 1.3
 60 │ Active │  80 │ 4.6.0              │ Apache XBean OSGI Bundle Utilities
 61 │ Active │  80 │ 4.6.0              │ Apache XBean :: Classpath Resource
Finder
 89 │ Active │  80 │ 6.2.0              │ org.objectweb.asm
 90 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.commons
 91 │ Active │  80 │ 6.2.0              │ org.objectweb.asm.tree
 98 │ Active │  80 │ 1.1.0.201802012106 │
org.osgi:org.osgi.service.http.whiteboard
 99 │ Active │  80 │ 1.0.0.201802012106 │ org.osgi:org.osgi.service.jaxrs
100 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.function
101 │ Active │  80 │ 1.1.0.201802012106 │ org.osgi:org.osgi.util.promise
102 │ Active │  80 │ 1.0.0.SNAPSHOT     │ de.rest.test.whiteboard.ds Bundle
103 │ Active │  80 │ 1.0.0.SNAPSHOT     │ rest-enroute
karaf@root()> /


With the command karaf@root()> service:list , I get (excerpt) :

/karaf@root()> service:list                                                                                              
[de.rest.test.ExampleRest]
--------------------------
 component.id = 2
 component.name = de.rest.test.ExampleRest
 osgi.jaxrs.application.select = (osgi.jaxrs.name=.default)
 osgi.jaxrs.resource = true
 service.bundleid = 102
 service.id = 123
 service.scope = bundle
Provided by : 
 de.rest.test.whiteboard.ds Bundle (102)

[val.rest.enroute.RestComponentImpl]
------------------------------------
 component.id = 3
 component.name = val.rest.enroute.RestComponentImpl
 service.bundleid = 103
 service.id = 124
 service.scope = bundle
Provided by : 
 rest-enroute (103)/

With the command karaf@root()> http:list , I get :

/karaf@root()> http:list
ID │ Servlet │ Servlet-Name │ State │ Alias │ Url
───┼─────────┼──────────────┼───────┼───────┼────
karaf@root()>  /

Yes, nothing. So no servlet or something in that regard is registered. It
can not work, right? 

When I install the feature cxf-jaxrs I get this:

/karaf@root(feature)> http:list
ID  │ Servlet             │ Servlet-Name               │ State       │ Alias
│ Url
────┼─────────────────────┼────────────────────────────┼─────────────┼───────┼─────────
114 │ CXFNonSpringServlet │ cxf-osgi-transport-servlet │ Deployed    │ /cxf 
│ [/cxf/*]
karaf@root(feature)/


I assume I am missing something obvious and substantial. Can someone point
me to what I am missing?

Thanks in advance!


Greetings,

Adnan






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

Re: REST - Declarative Services

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

My example works for the http whiteboard, but not Aries JAXRS 
whiteboard. For JAXRS, I provided example based on CXF.

If CXF is not convenient for you, I can add a Aries JAXRS Whiteboard 
example, no problem.

If your case, 404 means that the "listener servlet" has not been 
deployed or not on the alias you expect.

Did you check what you have with http:list command ?

Regards
JB


On 05/09/2018 16:18, atouat wrote:
> Hello to everybody,
>
> I wanted to try out using Aries JAXRS Whiteboard, since there is released
> version now.
>
> For this, I have donwloaded a new Karaf 4.2.1. I created a feature in order
> to install Aries Jaxrs Whiteboard.
>
> The feature.xml looks like this:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"
> name="aries-jaxrs-whiteboard">
>      <feature name="aries-jaxrs-whiteboard"
> description="aries-jaxrs-whiteboard" version="1.0.0">
>          <feature>http-whiteboard</feature>
>
> <bundle>mvn:org.apache.aries.spec/org.apache.aries.javax.jax.rs-api/1.0.0</bundle>
>
> <bundle>mvn:org.apache.felix/org.apache.felix.http.servlet-api/1.1.2</bundle>
>
> <bundle>mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.annotation-api-1.3/1.3_1</bundle>
>          <bundle>mvn:org.osgi/org.osgi.service.http.whiteboard/1.1.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.service.jaxrs/1.0.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.util.function/1.1.0</bundle>
>          <bundle>mvn:org.osgi/org.osgi.util.promise/1.1.0</bundle>
>
> <bundle>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.whiteboard/1.0.0</bundle>
>      </feature>
> </features>
>
> I have now all bundles active.
>
> I tried the code example from @jbonofre (the giothub link returns an HTTP
> 404 error). My bundle was deplyoed and active, but I could not access my
> rest service.
>
> I tried to url http://loclahost:8181/myName but there was no response at
> all.
>
> What am I missing? Can someone provide a working example with Aris JAXRS
> Whiteboard please?
>
>
> Greetings,
>
> Adnan
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html