Endpoints Frameworks 2.0迁移后,端点Api调用未完成。
以下是堆栈跟踪:
Problem accessing /_ah/api/discovery/v1/apis/EndpointApp/v1/rest. Reason:
com.google.api.server.spi.Strings.stripSlash(Ljava/lang/String;)Ljava/lang/String;
Caused by:
java.lang.NoSuchMethodError: com.google.api.server.spi.Strings.stripSlash(Ljava/lang/String;)Ljava/lang/String;
at com.google.api.server.spi.EndpointsServlet.service(EndpointsServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:58)
at com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
浏览器会显示错误消息,例如API discovery response missing required fields.
我已按照getting started guide中提供的详细信息和已更新的web.xml
文件。
希望有人可以解释错误!
pom.xml
档案:
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.0.7</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.sdk.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>GetSwaggerDoc</id>
<activation>
<property>
<name>GetSwaggerDoc</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>com.google.api.server.spi.tools.EndpointsTool</mainClass>
<arguments>
<argument>get-swagger-doc</argument>
<argument>--hostname=echo-api.endpoints.${appengine.app.id}.cloud.goog</argument>
<argument>--war=target/${project.artifactId}-${project.version}</argument>
<argument>com.test.api.Endpoint</argument>
</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework-tools</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.sdk.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<hostname>${appengine.app.id}.appspot.com</hostname>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
</resource>
<resource>
<!-- resources in src/main/resources, deployed to WEB-INF/res, not filtered -->
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<targetPath>WEB-INF/res</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<cloudSdkPath>/Applications/google-cloud-sdk</cloudSdkPath>
<port>8080</port>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:2)
我遇到了同样的问题。事实证明,因为我从Eclipse风格项目迁移,我在WEB-INF / lib文件夹中有旧jar。 这些不是必需的,因为gradle构建具有正确的依赖性。 我删除了 WEB-INF / lib文件夹并重新部署了中提琴!
答案 1 :(得分:2)
我也有同样的问题。在我的情况下,我不可能简单地删除整个WEB-INF / lib目录(很少有外部合作伙伴不公开他们的库)。
以下是我们必须做的事情:
错误消失,测试后所有端点似乎都正常工作。享受!