2012-10-06 50 views
1

我在使用Jersey的Google App Engine中部署示例應用。但是,當我嘗試執行GET或POST到REST資源時,我得到一個 - 404 NOT FOUND錯誤。看起來我錯過了一些東西。Jersey Google應用引擎 - 資源未找到

REST資源代碼:

import javax.ws.rs.Consumes; 
    import javax.ws.rs.GET; 
    import javax.ws.rs.POST; 
    import javax.ws.rs.Path; 
    import javax.ws.rs.Produces; 
    import javax.ws.rs.core.MediaType; 

    import org.codehaus.jettison.json.JSONObject; 

    @Path("/stream") 
    public class StreamingResource { 
     private static final Logger log = Logger 
     .getLogger(FacebookStreamingResource.class.getName()); 

     @POST 
     @Path("/callback") 
     @Consumes(MediaType.APPLICATION_JSON) 
     @Produces(MediaType.TEXT_PLAIN) 
     public String putStreamData(JSONObject jsonEntity) { 
      return jsonEntity.toString(); 
     } 

     @GET 
     @Path("/get") 
     @Produces(MediaType.TEXT_PLAIN) 
     public String getStreamData() { 
      return "Get successful"; 
     } 
    } 

這裏是

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 
     <servlet> 
      <servlet-name>SystemServiceServlet</servlet-name> 
      <servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class> 
      <init-param> 
       <param-name>services</param-name> 
       <param-value /> 
      </init-param> 
     </servlet> 
     <servlet-mapping> 
      <servlet-name>SystemServiceServlet</servlet-name> 
      <url-pattern>/_ah/spi/*</url-pattern> 
     </servlet-mapping> 

     <servlet> 
      <servlet-name>JerseyWebApplication</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.vbv.fb</param-value> 
      </init-param> 
      <load-on-startup>1</load-on-startup> 
     </servlet> 
     <servlet-mapping> 
      <servlet-name>JerseyWebApplication</servlet-name> 
      <url-pattern>/stream/*</url-pattern> 
     </servlet-mapping> 
     <session-config> 
      <session-timeout>30</session-timeout> 
     </session-config> 
    </web-app> 

我已經包括以下罐子web.xml文件:

ASM-3.1.jar 球衣,客戶端 - 1.12.jar jersey-core-1.12.jar jersey-json-1.12.jar jersey-server-1.12.jar 新澤西州的servlet-1.12.jar 拋放-1.1.jar 傑克遜核心ASL-1.7.1.jar 傑克遜JAXRS-1.7.1.jar 傑克遜映射器-ASL-1.7.1.jar 傑克遜-xc-1.7.1.jar

的App Engine SDK版本是1.7.0

任何建議,將不勝感激:)

回答

0

當我改變了在web.xml從/流/ *到/ *它的工作原理:)

+0

是的。否則,它期待/流/流/ *工作。 – husayt