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.bra...@gmail.com
>> <mailto:nicolas.bra...@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é <j...@nanthrax.net
>> <mailto:j...@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é
>>     jbono...@apache.org <mailto:jbono...@apache.org>
>>     http://blog.nanthrax.net <http://blog.nanthrax.net/>
>>     Talend - http://www.talend.com <http://www.talend.com/>
>>
> 

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

Reply via email to