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.

Reply via email to