1

我的 Web.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
 <servlet-mapping>
 <servlet-name>javax.ws.rs.core.Application</servlet-name>
 <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>
</web-app>

我的应用程序配置类如下:

@ApplicationPath("/api/catalogManagement/v2")
public class ApplicationConfig extends ResourceConfig

我的休息服务类如下:

@Stateless
@Path("/catalog")
public class CatalogFacadeREST extends AbstractFacadeREST<CatalogEntity> {
    @GET
    @Produces({MediaType.APPLICATION_JSON})
    public Response find(@QueryParam("depth") int depth, @Context UriInfo uriInfo) throws BadUsageException {
}
}

我正在调用这个休息服务:http://localhost:8080/DSPRODUCTCATALOG2/rest/api/catalogManagement/v2/catalog?depth=5

但我得到:

21:17:53,739 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-1) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/DSPRODUCTCATALOG2/rest/api/catalogManagement/v2/catalog?depth=5
        at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)
        at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)
4

3 回答 3

0

我猜你已经在你的应用程序类(或配置类)中覆盖了“getClasses”方法。结果,如果这些类不存在,则配置不可见...

于 2018-12-18T03:35:55.537 回答
0

当然,您的配置存在一些问题。您不必添加

<servlet-mapping>
 <servlet-name>javax.ws.rs.core.Application</servlet-name>
 <url-pattern>/rest/*</url-pattern>
 </servlet-mapping>

在您的 web .xml 中作为 javax.ws.rs.core.Application 根本不是 servlet。相反,您必须像这样配置;

@ApplicationPath("/<your path>")
public class ApplicationReSTService extends Application {
}

用你的相对路径给出正斜杠也没有问题。

于 2016-08-28T04:38:31.717 回答
0

我相信这是问题所在:

@ApplicationPath("/api/catalogManagement/v2")

应该是,没有前导斜杠

@ApplicationPath("api/catalogManagement/v2")

资源

于 2016-03-21T16:05:23.633 回答