RESTEasy - javax.ws.rs.NotFoundException: impossible de trouver des ressources pour le chemin d'accès complet

J'ai essayé de mettre en œuvre un service REST avec RESTEasy dans un projet GWT, mais quand je reçois à l'URI de l'application retourne:

Grave: failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://127.0.0.1:8888/api/matches
    at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:73)
    at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
    at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:444)
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:234)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:171)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Mon web.xml est:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <!-- All REST resources will be prefixed by /api -->
  <context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/api</param-value>
  </context-param>

  <!-- Servlets -->
  <servlet>
    <servlet-name>Resteasy</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>eii.api.MatchApplication</param-value>
    </init-param>
  </servlet>

  <!-- Servlet mappings -->
  <!-- All calls to /api/xxx will be sent to the reasy servlet -->
  <servlet-mapping>
    <servlet-name>Resteasy</servlet-name>
    <url-pattern>/api/*</url-pattern>
  </servlet-mapping>

</web-app>

La mise en œuvre de la Demande:

public class MatchApplication extends Application {
    private Set<Object> singletons = new HashSet<Object>();
    private Set<Class<?>> classes = new HashSet<Class<?>>();

    public MatchApplication() {
        singletons.add(new MatchServiceImpl());
    }

    @Override
    public Set<Class<?>> getClasses() {
        return classes;
    }

    @Override       
    public Set<Object> getSingletons() {
        return singletons;
    }
}

Et voici la classe qui fournissent le service REST:

 /* Imports */
    ...
@Path("/matches")
public class MatchResource {
    private static MatchResource _instance = null;
    private MatchRepository repository;

    public MatchResource() {
        repository = new MapMatchRepository(); 
    }

    public static MatchResource getInstance() {
        if (_instance == null)
            _instance = new MatchResource();
        return _instance;
    }

    @GET
    @Path("/{id}")
    @Produces("application/json")
    public Match getMatch(@PathParam("id") int id) {
        return repository.getMatch(id);
    }

    @GET
    @Produces("application/json")
    public Matches getMatchesCurrentRound() {
        return repository.getMatchesCurrentRound();
    }

        ...
}

Ce que je veux, c'est le retour d'un fichier JSON lors de l'obtention dans, par exemple: http://127.0.0.1:8888/api/matches

Personne ne sait ce que je fais mal?

Edit:

Si j'ai accès à http://127.0.0.1:8888/api/ ou http://127.0.0.1:8888/api/* (où * est-ce que vous voulez l'écrire), le navigateur affiche rien. Cependant, si j'ai accès à http://127.0.0.1:8888/oqiwn (où oqiwn est une chaîne aléatoire) le navigateur affiche une Error 404.

Aussi, j'ai essayé la RESTClient addon et ce sont les réponses qui renvoie:

Avec http://127.0.0.1:8888/api/ ou http://127.0.0.1:8888/api/*

Status Code: 404 Not Found
Cache-Control: no-cache
Content-Length: 0
Date: Sun, 10 Nov 2013 22:59:57 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Server: Development/1.0

Et avec http://127.0.0.1:8888/oqiwn

Status Code: 404 Not Found
Cache-Control: no-cache
Content-Length: 83
Content-Type: text/html; charset=iso-8859-1
Date: Sun, 10 Nov 2013 22:59:05 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Server: Development/1.0

Noter que Content-Type: text/html; charset=iso-8859-1 n'est pas dans le premier.

Commentaire de James Lyell: faut-il travailler si vous modifiez le @Path: @Path("/api/matches")?

OriginalL'auteur Kaer | 2013-11-09