2017-10-12 754 views
1

我面临以下问题,找不到解决方案来解决它。错误[org.jboss.resteasy.resteasy_jaxrs.i18n](默认任务-2)RESTEASY002010

我的堆栈跟踪到这里:

ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-2) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY: Could not find resource for full path: http://localhost:8080/myProjectName 
    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) 
    at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:257) 
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:194) 
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221) 
    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:790) 
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85) 
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) 
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) 
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.keycloak.adapters.undertow.UndertowAuthenticatedActionsHandler.handleRequest(UndertowAuthenticatedActionsHandler.java:66) 
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) 
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) 
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) 
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) 
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) 
    at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) 
    at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at org.keycloak.adapters.undertow.ServletPreAuthActionsHandler.handleRequest(ServletPreAuthActionsHandler.java:69) 
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) 
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285) 
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264) 
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81) 
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175) 
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202) 
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
    at java.lang.Thread.run(Thread.java:748) 

这里是我的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app 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" 
      version="3.1"> 
     <context-param> 
      <param-name>resteasy.role.based.security</param-name> 
      <param-value>true</param-value> 
     </context-param> 

     <security-constraint> 
      <web-resource-collection> 
       <web-resource-name>pcpd</web-resource-name> 
       <url-pattern>/*</url-pattern> 
      </web-resource-collection> 
      <auth-constraint> 
       <role-name>administrator</role-name> 
      </auth-constraint> 
     </security-constraint> 

     <login-config> 
      <auth-method>BASIC</auth-method> 
     </login-config> 

    <security-role> 
     <role-name>administrator</role-name> 
    </security-role> 
</web-app> 

应用类:

@ApplicationPath("/") 
public class LauncherWebServices extends Application{ 
} 

类与服务

@Path("/folders") 
@RequestScoped 
public class PageServicesREST { 
     @GET 
    @Path("/retrievePage") 
    @Produces(MediaType.APPLICATION_JSON) 
    public Response getListPage() { 
     List<Page> list = pageBusiness.retrievePage(); 
     if (list == null) { 
      return Response.ok().entity("Liste des pages est vide").build(); 
     } 
     return Response.ok().entity(pageBusiness.retrievePage()).build(); 
    } 
} 

现在,当我运行的应用程序,我得到这个错误(堆栈跟踪)这样的网址:http://localhost:8080/myProjectName

但是,当我试图运行象下面这样的服务:

http://localhost:8080/myProjectName/folders/retrievePage 

它工作正常。

我错过了什么?

我曾尝试阅读其他解决方案在stackoverflow和文档RESTEASY但我找不到解决方案。 有没有人遇到过这样的问题?

+0

那么,你得到的错误,因为你的根url(/)没有映射到任何地方。尝试映射你的根网址到一些东西。 –

+0

我可以这样做吗? – user1814879

回答

1

您的错误信息在我看来并不是致命的。你得到这个错误是因为你没有映射你的根URL(/)。要避免这种情况,你可以映射你的根URL的东西,例如:

@Path("/") 
@RequestScoped 
public class Root { 
    @GET 
    public Response index() { 
     return Response.ok().build(); 
    } 
} 

编辑:与其在同一类的映射根URL,把它放在另一个类,因为你已经PageServiceREST指定folders路径。

+0

好吧,我知道了,但是当我尝试它不起作用时......我在@ApplicationPath类中添加了它,但没有奏效 – user1814879

+0

哎呀抱歉,我忘记了你的类已经指定了'folders' url。我改变我的例子。现在我将根URL映射到不同的类 –