Ravi
Ravi

Reputation: 153

jax rs 2.0 annotation inheritance not working

I'm reading Bill Burke's Rest services with Jax rs 2.0 book. However, I'm stuck at this point.

If I create a CustomerService as a concrete class with annotations, my IDE is picking it up as a RestWebService and deploys it.

@Path("/customers")
public class CustomerService {
  ....
  @POST
  @Consumes("application/xml")
  public Response createCustomer(InputStream is) 
  ....
}

But if use an interface and annotate it, and implement it in a class (the concrete class doesnt have annotations), the ide doesnt recognise it. I get HTTP 404 error status.

I'm using Netbeans 7.4 and JBoss AS 6.2.

Please help! Thanks.

Upvotes: 0

Views: 301

Answers (1)

Qwertovsky
Qwertovsky

Reputation: 1106

From specification:

A resource class is a Java class that uses JAX-RS annotations to implement a corresponding Web resource. Resource classes are POJOs that have at least one method annotated with @Path or a request method designator.

You can't load classes without annotations as resources.

Upvotes: 1

Related Questions