目前,当我尝试使用Tomcat运行RestEasy时,我遇到了一个问题。
我添加了所有相应的罐子。
但我无法理解导致问题的原因。
下面我已经提供了所有配置细节和我使用的资源。
服务器:Tomcat版本7我正在使用它。
有人可以帮我解决问题,如果遗漏任何问题,请告诉我。
错误记录
9 Sep, 2015 10:30:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.30
9 Sep, 2015 10:30:05 PM org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap
WARNING: resteasy.scan is no longer supported. Use a servlet 3.0 container and the ResteasyServletInitializer
9 Sep, 2015 10:30:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
9 Sep, 2015 10:30:06 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
9 Sep, 2015 10:30:06 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1792 ms
9 Sep, 2015 10:31:15 PM org.jboss.resteasy.core.ExceptionHandler
SEVERE: failed to execute
javax.ws.rs.NotFoundException: Could not find resource for full path: http://localhost:8080/web-layer/rest/vechicle
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:255)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:192)
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)
LIB配置
WebContent\WEB-INF\lib\activation-1.1.1.jar
WebContent\WEB-INF\lib\commons-codec-1.6.jar
WebContent\WEB-INF\lib\commons-io-2.1.jar
WebContent\WEB-INF\lib\commons-logging-1.1.3.jar
WebContent\WEB-INF\lib\httpclient-4.3.6.jar
WebContent\WEB-INF\lib\httpcore-4.3.3.jar
WebContent\WEB-INF\lib\jaxrs-api-3.0.12.Final.jar
WebContent\WEB-INF\lib\jboss-annotations-api_1.1_spec-1.0.1.Final.jar
WebContent\WEB-INF\lib\jcip-annotations-1.0.jar
WebContent\WEB-INF\lib\resteasy-jaxrs-3.0.12.Final.jar
Web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>asf-lpa-web</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this need same with resteasy servlet url-pattern -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
服务界面
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/")
public interface ParkService {
@GET
@Path("/vechicle")
@Produces(MediaType.APPLICATION_JSON)
public Response getViewPark();
}
服务Impl Class
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.Response;
public class ParkServiceImpl implements ParkService{
public Response getViewPark(){
ViewTo viewTo = new ViewTo();
//
///
///
return response("view",viewTo);
}
private Response response(String jsonName, Object object) {
Map<String, Object> outputMap = new TreeMap<String, Object>();
outputMap.put(jsonName, object);
return Response.ok(outputMap).build();
}
}
答案 0 :(得分:0)
您可能面临与创建此问题的用户相同的问题:javax.ws.rs.NotFoundException: Could not find resource for full path
首先尝试将您的其余api版本更改为3.0.4.Final,如果您的应用程序使用它,那肯定是同样的问题。
答案 1 :(得分:0)
我认为问题是由于界面上的@Path注释造成的。显然,ResteastServletInitializer无法处理。
我很想知道如何让接口拥有@Path注释。