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é
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to