gpt4 book ai didi

web-services - 使用 Tomcat 运行 RestEasy Restful Webservice 时出现问题

转载 作者:行者123 更新时间:2023-11-28 23:29:26 26 4
gpt4 key购买 nike

目前我在尝试使用 Tomcat 运行 RestEasy 时遇到问题。

我添加了所有相应的jar。

但我无法理解导致问题的原因。

下面我给出了所有配置细节和我使用的资源。

服务器: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)

库配置

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>

服务接口(interface)

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();

}

服务实现类

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();
}

}

最佳答案

您可能面临与创建此问题的用户相同的问题:javax.ws.rs.NotFoundException: Could not find resource for full path

首先尝试将您的 rest api 版本更改为 3.0.4.Final,如果您的应用可以使用它,那么肯定是同样的问题。

关于web-services - 使用 Tomcat 运行 RestEasy Restful Webservice 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32486019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com