Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 545
terry207 Avatar asked Dec 06 '25 12:12

terry207


1 Answers

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)
  {
    ...
  }

}
like image 59
fmucar Avatar answered Dec 09 '25 00:12

fmucar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!