users@jersey.java.net

[Jersey] Inheritance and Internal Classes

From: <ghellings_at_onenetwork.com>
Date: Wed, 22 Dec 2010 22:38:51 +0000 (GMT)

I was very happy to get a Jersey resource working with inheritance. I
have a base class which looks pretty much like this:

public abstract class Base {
  protected Base(String arg) {...}
  @GET
   public String get() { ... }
  @POST
  public String set() { ... }
}

I can then extend that class like this:

@Path("/resource1")
public class ResourceOne {
  public ResourceOne() { super("arg value"); }
}

And this works fine. However I wanted to collect several extension
classes together if I can so they look like this

@Path("/simple")
public class Simple {
  @Path("/resource1")
  public class ResourceOne{
    public ResourceOne() { super("arg value"); }
  }
  @Path("/resource2")
  public class ResourceTwo{
    public ResourceTwo() { super("arg value"); }
  }
}

However, when I do this and try to access /simple/resource1, Jersey
gives me a com.sun.jersey.api.NotFoundException which I can only assume
means it is unable to locate the specified path on the nested classes.
Am I doing something terribly wrong here, or does Jersey not support
the nested class arrangement I have?

Thanks in advance.

--Greg