srv
srv

Reputation: 440

Endpoint Api Call Error after Endpoints Frameworks 2.0 Migration

Endpoint Api call is not going through after Endpoints Frameworks 2.0 migration.

Following is the stack trace:

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)

Browser gives a error message like this API discovery response missing required fields.

I have followed the details given in getting started guide and updated web.xml file.

Hope somebody can shed light on the error!

pom.xml file:

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

Upvotes: 1

Views: 555

Answers (2)

LMG
LMG

Reputation: 1370

Me too had the same issue. It was not possible in my case to simply get rid of the entire WEB-INF/lib directory (few external partners do not make their libraries public).

Here is what we had to do:

  1. Remove appengine-endpoints.jar from project build path
  2. Re-Deploy to App Engine

The error disappeared and all endpoints seem to be working fine after testing. Enjoy!

Upvotes: 2

AAP
AAP

Reputation: 1284

I had the same problem. Turns out because I had migrated from Eclipse style projects, I had older jars in WEB-INF/lib folder. Those are not required, since gradle build has the right dependencies. I deleted the WEB-INF/lib folder and re-deployed and viola!

Upvotes: 2

Related Questions