Paul,

I have extended the Application class as follows:

public class MyApplication extends Application {
    
          public Set<Class<?>> getClasses() {
              HashSet<Class<?>> set = new HashSet<Class<?>>();
              set.add(Rest.class);
              return set;
           }

}

Now the endpoint resolves.

But DS dependency injection does not work.
Is there something needed to switch this on?

-- Jaap

> -----Original Message-----
> From: Paul Spencer <[email protected]>
> Sent: maandag 23 januari 2023 15:16
> To: [email protected]
> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
> @JSONRequired result in 404
> 
> Jaap,
> JaxrsApplicationBase is used with JaxrsApplicationSelect to is required to use
> a non-default context, so your results confirm the default context is working.
> 
> Paul Spencer
> 
> > On Jan 23, 2023, at 9:08 AM, Jaap Gordijn <[email protected]> wrote:
> >
> > Paul,
> >
> > I did the following to create the application.
> >
> > @Component(service=Application.class, property =
> > {"servlet.init.hide-service-list-page=true"} )
> > @JaxrsApplicationBase("example")
> > @JaxrsName("MyApplication")
> > public class MyApplication extends Application {
> >
> > }
> >
> > The strange thing is at that if I remove the @JaxrsApplicationSelect in the
> Rest service class, then it works. But not with the Application class.
> >
> > -- Jaap
> >
> >> -----Original Message-----
> >> From: Paul Spencer <[email protected]>
> >> Sent: maandag 23 januari 2023 14:11
> >> To: [email protected]
> >> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
> >> @JSONRequired result in 404
> >>
> >> Jaap,
> >> Have you created the Jaxrs application?
> >>
> >> @Component(service=Application.class)
> >> @JaxrsName("MyApplication")
> >> @JaxrsApplicationBase("/example")
> >> public class MyApp extends Application{
> >>
> >> }
> >>
> >> Paul Spencer
> >>
> >>>> On Jan 23, 2023, at 7:39 AM, Jaap Gordijn <[email protected]> wrote:
> >>>
> >>> Paul,
> >>>
> >>> I used the features as you suggested.
> >>>
> >>> In the log, I see that the Jetty container starts.
> >>> Also the context path is registered:
> >>> Registering
> >>> OsgiServletContext{model=OsgiContextModel{WB,id=OCM-
> >> 5,name='context.fo
> >>> rMyApplication',path='/example',bundle=org.apache.aries.jax.rs.white
> >>> bo ard,ref=[org.osgi.service.http.context.ServletContextHelper]}} as
> >>> OSGi service for "/example" context pat
> >>>
> >>> But then I get this:
> >>> org.apache.cxf.cxf-rt-transports-http - 3.5.5 | Can't find the
> >>> request for http://172.20.116.137:8181/example/person's Observer
> >>>
> >>> Best,
> >>>
> >>> -- Jaap
> >>>
> >>>> -----Original Message-----
> >>>> From: Paul Spencer <[email protected]>
> >>>> Sent: maandag 23 januari 2023 13:13
> >>>> To: [email protected]
> >>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
> >>>> and @JSONRequired result in 404
> >>>>
> >>>> Jaap,
> >>>> 1) You can use the web: commands to verify the expected context
> >>>> exists
> >>>> 2) Review karaf.log  to verify the the bundle startup and post
> >>>> relevant errors
> >>>> 3) I use the following features:
> >>>> <feature>jackson</feature>
> >>>> <feature>pax-web-http-whiteboard</feature>
> >>>> <feature>aries-jax-rs-whiteboard</feature>
> >>>> <feature>aries-jax-rs-whiteboard-jackson</feature>
> >>>>
> >>>> Paul Spencer
> >>>>
> >>>>>> On Jan 23, 2023, at 4:49 AM, Jaap Gordijn <[email protected]> wrote:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> I have a problem with aries-jax-rs-whiteboard and the use of
> >>>>> @JaxrsApplicationSelect and @JSONRequired in combination.
> >>>>> That results in an inaccessible service (404).
> >>>>> If I disable the JSON annotations, the /test service works (via
> >>>>> /example/text
> >>>>>
> >>>>> Code:
> >>>>>
> >>>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
> >>>>> @JaxrsResource @JaxrsApplicationSelect("(" +
> >>>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
> >>>>> "=MyApplication)")
> >>>>> @JSONRequired
> >>>>> @Produces(MediaType.APPLICATION_JSON)
> >>>>> public class Rest {
> >>>>>
> >>>>>  @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
> >>>>>  private volatile PersonService personService;
> >>>>>
> >>>>>  @GET
> >>>>>  @Path("/person")
> >>>>>  public List<PersonDto> listPersons() {
> >>>>>      return personService.select();  }
> >>>>>
> >>>>>  @GET
> >>>>>  @Path("/test")
> >>>>>  public String test() {
> >>>>>      return "test";
> >>>>>  }
> >>>>> }
> >>>>>
> >>>>> @Component(service=Application.class, property =
> >>>>> {"servlet.init.hide-service-list-page=true"} )
> >>>>> @JaxrsApplicationBase("example")
> >>>>> @JaxrsName("MyApplication")
> >>>>> public class MyApplication extends Application {
> >>>>>
> >>>>> }
> >>>>>
> >>>>>
> >>>>> <repository>mvn:org.apache.cxf.karaf/apache-
> cxf/3.5.5/xml/features
> >>>>> </
> >>>>> re
> >>>>> posito
> >>>>> ry>
> >>>>>
> >>>>> <repository>mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.fe
> >>>>> at
> >>>>> ur
> >>>>> es/2.0
> >>>>> .2/xml</repositor
> >>>>>     ....
> >>>>>     <feature>hibernate</feature>
> >>>>>     <feature>hibernate-validator</feature>
> >>>>>     ...
> >>>>>
> >>>>> I use Karaf 4.4.3
> >>>>>
> >>>>> Any ideas?
> >>>>>
> >>>>> Best,
> >>>>>
> >>>>> -- Jaap
> >>>>>
> >>>
> >

Reply via email to