terry207
terry207

Reputation: 775

RestEasy path solving

I get something like this

import javax.ws.rs.GET;
import javax.ws.rs.Path;

public class xxx
{

  @GET
  @Path(value = "path1")
  public Response m1(@QueryParam(value = "a") String a)
  {
    ...
  }



  @GET
  @Path(value = "path2")
  public Response m2(@QueryParam(value = "b") String b)
  {
    ...
  }

}

With restEasy I get HTTP Status 404 - Could not find resource for relative every time when i try to get path1 or path2 For ex http://someip:8080/myserv/services/path1?a=asd

Here http://docs.jboss.org/resteasy/docs/1.2.GA/userguide/html_single/#Using_Path I read

The @javax.ws.rs.Path annotation must exist on either the class and/or a resource method. If it exists on both the class and method, the relative path to the resource method is a concatenation of the class and method.

Upvotes: 3

Views: 10335

Answers (2)

Mike
Mike

Reputation: 8555

Did you try removing the value= in your path notation? I'm not 100% on what the value= is used for since I'm quite new to JAX-RS but maybe try out just doing:

@GET  
@Path("path1")  
public Response m1(@QueryParam(value = "a") String a)  
{  
  ...  
}  

Upvotes: 0

fmucar
fmucar

Reputation: 14558

Remove services if it is not a part of your servlet mapping or path.

(Also more info about your path/servlet mapping will make us understand better)

EDIT:

So your project is deployed with myapp context name + you have services prefix + path defined in resource class.+ servlet mapping is /* so /myapp/services/path should work.

You can increase the logging level for resteasy classes to see what is wrong. or in debug mode you can see what path is requested in PathHelper.replaceEnclosedCurlyBraces

EDIT2:

If you are auto scanning, classes needs to be annotated with @Provider

Resteasy v1.2.1

@Provider
@Path("/")
public class xxx
{

  @GET
  @Path(value = "path1")
  public Response m1(@QueryParam(value = "a") String a)
  {
    ...
  }



  @GET
  @Path(value = "path2")
  public Response m2(@QueryParam(value = "b") String b)
  {
    ...
  }

}

Upvotes: 1

Related Questions