【发布时间】:2012-04-22 08:21:28
【问题描述】:
关于如何集成 Jetty 和 RESTEasy 的任何链接?我在尝试将 RESTEasy 与 Jetty 一起配置时有点卡住了……而且似乎在网络上没有可靠的帮助。
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setDescriptor("../WEB-INF/web.xml");
context.setResourceBase("../src/webapp");
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
}
我的 Web.xml 直接复制自: http://docs.jboss.org/resteasy/docs/1.0.0.GA/userguide/html/Installation_Configuration.html
当我尝试打开资源文件中的链接时,返回的错误是 HTTP 404。一切表面上看起来都很合理,有什么建议吗?
我的资源文件如下:
package webapp;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@Path("/*")
public class Resource {
@GET
public String hello() {
return "hello";
}
@GET
@Path("/books")
public String getBooks() {
return "books";
}
@GET
@Path("/book/{isbn}")
public String getBook(@PathParam("isbn") String id) {
return "11123";
}
}
这是我在 Jetty 启动时看到的打印:
2012-04-10 09:54:27.163:INFO:oejs.Server:jetty-8.1.1.v20120215 2012-04-10 09:54:27.288:INFO:oejw.StandardDescriptorProcessor:NO JSP 支持 /,没有找到 org.apache.jasper.servlet.JspServlet 2012-04-10 09:54:27.319:INFO:oejsh.ContextHandler:started oejwWebAppContext{/,file:/C:/Users/xyz/Anotherproj1/src/webapp } 2012-04-10 09:54:27.319:INFO:oejsh.ContextHandler:started oejwWebAppContext{/,file:/C:/Users/xyz/Anotherproj1/src/webapp} 2012-04-10 09:54:27.381 :INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:8080
【问题讨论】:
-
乍一看,这看起来是正确的。您使用的是哪个 Jetty 版本。是否有任何错误信息?你到底有什么问题?
-
@andih 当我尝试打开资源文件中的链接时,该错误本质上是 HTTP 404。
-
@andih 我正在使用 Jetty 8.1.1
标签: java jakarta-ee servlets jetty resteasy