Hi

JAX-RS 2.0 ResourceContext is supported from CXF 2.7.2, which version do you use ? FYI, I'd not use ResourceContext myself unless there's a good reason a subresource instance can not get required contexts propagated to it from a parent resource - it makes things more complex IMHO :-)

Cheers, Sergey
On 22/07/13 19:07, Nick Khamis wrote:
Hello Everyone,

I have the following resource running on tomcat:

@Context
     ResourceContext rc;

     Map<String, Bean> bc;

     @POST
     public void init() {
         this.bc = new ConcurrentHashMap<String, Bean>();
     }

     @GET
     public Collection<Bean> allBeans() {
         return bc.values();
     }

     @GET
     @Path("{id}")
     public Bean bean(@PathParam("id") String id) {
         return bc.get(id);
     }

     @POST
     public Response add(Bean bean) {
         if (bean != null) {
             bc.put(bean.getName(), bean);
         }
         final URI id = URI.create(bean.getName());
         return Response.created(id).build();
     }

     @DELETE
     @Path("{id}")
     public void remove(@PathParam("id") String id) {
         bc.remove(id);
     }

     @Path("/roaster/{id}")
     public RoasterResource roaster(){
         return this.rc.initResource(new RoasterResource());
     }

For now I am trying to invoke the different resource using curl. Now, I am
trying to run:

@Path("/roaster/{id}")
     public RoasterResource roaster(){
         return this.rc.initResource(new RoasterResource());
     }

to initialize a new instance of RoasterResource however, not able to do so.
Can someone please help me in invoking this service without getting hit
with "null pointer exception" please!

Kind Regards,

Nick.



--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to