title: Inheritance with JAX-RS
body: <p>I am using <code>JAX-RS</code> for my web services. I have common functionality and would like to use inheritance. I am providing simple CRUD operations. I have defined an interface like so:</p>
  
  <pre><code>public interface ICRUD {
  
      @POST
      @Consumes("application/json")
      @Produces("application/json")
      @Path("create")
      public String createREST(String transferObject);
  
      @GET
      @Consumes("application/json")
      @Produces("application/json")
      @Path("retrieve/{id}")
      public String retrieveREST(@PathParam("id") String id);
  
      @POST
      @Consumes("application/json")
      @Produces("application/json")
      @Path("update")
      public void updateREST(@Suspended final AsyncResponse asyncResponse,
                             final String transferObject) ;
  
      @DELETE
      @Consumes("application/json")
      @Produces("application/json")
      @Path("delete/{id}")
      public String deleteREST(@PathParam("id") String id); 
  }
  </code></pre>
  
  <p>I have an abstract class that implements this interface:</p>
  
  <pre><code>public abstract class BaseREST implements ICRUD{
  
  private final ExecutorService executorService = Executors.newCachedThreadPool();
  
  @Override
  public String createREST(String transferObject) {
      return create(transferObject).toJson();
  }
  
  @Override
  public String retreiveREST(@PathParam("id") String id) {
      return retreive(id).toJson();
  }
  
  
  @Override
  public String deleteREST(
          @PathParam("id") String id) {
      return delete(id).toJson();
  }
  
  @Override
      public void updateREST(@Suspended final AsyncResponse asyncResponse, final String transferObject) {
          executorService.submit(new Runnable() {
              @Override
              public void run() {
                  asyncResponse.resume(doUpdateREST(transferObject));
              }
          });
      }      
  
  }
  </code></pre>
  
  <p>And lastly, my implementing class simply provides a PATH for the resource:</p>
  
  <pre><code>@Path("meeting")
  public class MeetingRestServices extends BaseREST {
  }
  </code></pre>
  
  <p>When I try to access my resource at (assuming the context root is /):</p>
  
  <pre><code>http://localhost:8080/webresources/meeting/retreive/0
  </code></pre>
  
  <p>I get a 404, it says it can not find it. My thoughts are that somewhere in the inheritance, it is messing with the path of where I think the resource should be. Any thoughts on this?</p>
  
  <h2>EDIT</h2>
  
  <p>webresources is defined below. This class is added automatically by Netbeans.</p>
  
  <pre><code>@javax.ws.rs.ApplicationPath("webresources")
  public class ApplicationConfig extends Application {
  
      @Override
      public Set&lt;Class&lt;?&gt;&gt; getClasses() {
          Set&lt;Class&lt;?&gt;&gt; resources = new java.util.HashSet&lt;&gt;();
          addRestResourceClasses(resources);
          return resources;
      }
  
      /**
       * Do not modify addRestResourceClasses() method.
       * It is automatically populated with
       * all resources defined in the project.
       * If required, comment out calling this method in getClasses().
       */
      private void addRestResourceClasses(Set&lt;Class&lt;?&gt;&gt; resources) {
          resources.add(com.dv.meetmefor.ws.impl.BinaryDataRestService.class);
          resources.add(com.dv.meetmefor.ws.impl.ImageRestServices.class);
          resources.add(com.dv.meetmefor.ws.impl.LocaleRestService.class);
          resources.add(com.dv.meetmefor.ws.impl.MeetUpRestServices.class);
          resources.add(com.dv.meetmefor.ws.impl.MeetingRestServices.class);
          resources.add(com.dv.meetmefor.ws.impl.UserAccountRestServices.class);
      }
  
  }
  </code></pre>