简体   繁体   中英

AppEngine: REST with Jersey not working

Within SpringSource Tool Suite I created a standard google app engine project. I added Jersey for REST support. 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....

Here the main files:

web.xml looks like this.

<?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.

The only Java class in com.sibib.main is 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. 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.

These are the lib referenced in the project:

  • activation-1.1.1.jar
  • appengine-api-1.0-sdk-1.6.1.jar
  • appengine-api-labs-1.6.1.jar
  • appengine-jsr107cache-1.6.1.jar
  • asm-3.3.1.jar
  • datanucleus-appengine-1.0.10.final.jar
  • datanucleus-core-1.1.5.jar
  • datanucleus-jpa-1.1.5.jar
  • geronimo-jpa_3.0_spec-1.1.1.jar
  • geronimo-jta_1.1_spec-1.1.1.jar
  • google_sql.jar
  • jackson-core-asl-1.9.2.jar
  • jackson-jaxrs-1.9.2.jar
  • jackson-mapper-asl-1.9.2.jar
  • jaxb-api-2.2.4.jar
  • jaxb-impl-2.2.4-1.jar
  • jdo2-api-2.3-eb.jar
  • jersey-bundle-1.11.jar
  • jersey-client-1.11.jar
  • jersey-core-1.11.jar
  • jersey-json-1.11.jar
  • jersey-server-1.11.jar
  • jettison-1.1.jar
  • jsr107cache-1.1.jar
  • persistence-api-1.0.2.jar
  • stax-api-1.0-2.jar

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 ,它对我没有任何问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM