2016-03-21 27 views
0

我的web.xml文件中如下:Wildfly 10 + Rest輕鬆的網絡服務。爲獲取完整路徑錯誤無法找到資源

<?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: RESTEASY: 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) 
+0

我使用澤西類,如:import org.glassfish.jersey.server.ResourceConfig;在ApplicationConfig Java文件中。但Wildfly 10默認使用Rest Easy。這是否導致問題? – user3921892

回答

0

我相信這是問題:

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

應該可以了,而不斜線

@ApplicationPath("api/catalogManagement/v2") 

source

+0

嗨Woot4Moo,我也試過這個。但不工作:(。請幫助... – user3921892

0

還有就是當然你的配置有一些問題。你不必在你的網頁的.xml添加

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

爲javax.ws.rs.core.Application不是一個servlet的。相反,你必須這樣配置;

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

此外,在給予您的相對路徑的斜槓方面也沒有問題。