[英]AppEngine: REST with Jersey not working
Within SpringSource Tool Suite I created a standard google app engine project. 在SpringSource Tool Suite中,我创建了一个标准的Google App Engine项目。 I added Jersey for REST support. 我添加了Jersey支持REST。 The development server starts up fine, but when I try to GET a URL (eg http://localhost:8888/sibibjersey/api ) I'm simply getting a 404. I suppose this is a simple configuration issue, but the solutions seems to hide away from me.... 开发服务器启动正常,但是当我尝试获取URL(例如http:// localhost:8888 / sibibjersey / api )时,我只是得到404。我想这是一个简单的配置问题,但是解决方案似乎躲开我...
Here the main files: 这里是主要文件:
web.xml looks like this. 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_2_5.xsd" version="2.5">
<init-param>
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
<param-value>true</param-value>
</init-param>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.sibib.main</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
I tried variations of the url-pattern like /* and /rest/*, but none seemed to work. 我尝试了/ *和/ rest / *这样的url模式的变体,但似乎没有一个起作用。
The only Java class in com.sibib.main is InfoResource.java: com.sibib.main中唯一的Java类是InfoResource.java:
package com.sibib.main;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/api")
public class InfoResource {
@GET
public String info() {
return "Hello Jersey on Google App Engine";
}
}
I tried adding @Path to the info function, but no effect. 我尝试将@Path添加到info函数,但是没有效果。 When I start the server and navigate eg to http://localhost:8888/sibibjersey/api I'm simply getting a 404. Loading http://localhost:8888 loads the index.html in the war folder. 当我启动服务器并导航到http:// localhost:8888 / sibibjersey / api时,我只是得到一个404。加载http:// localhost:8888会在war文件夹中加载index.html。
These are the lib referenced in the project: 这些是项目中引用的库:
Any hint is greatly appreciated! 任何提示,不胜感激!
Thanks! 谢谢!
您能尝试从上下文路径中删除sibibjersey吗,只需尝试使用http:// localhost:8888 / api在我的本地环境中,我还没有看到Google App Engine的应用程序具有http:// localhost:8888的项目路径,所以我遵循了http: //tugdualgrall.blogspot.com/2010/02/create-and-deploy-jax-rs-rest-service.html ,它对我没有任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.