0

I've built a test API in a new Maven-based App Engine Standard project created in Eclipse. Upon adding API Management and deploying on production server, I get a 500 response when trying out the API on the Endpoints Portal. Error logs in the dashboard show the following exception:

endpoints.repackaged.com.google.api.config.ServiceConfigException: 
Failed to fetch default config version for service 'networking-1088.appspot.com'.
No versions exist!

I checked out similar questions like this one but I have used the project ID as the service name consistently across files, have not included service version, and have used all the necessary boilerplate code from the documentation.

Below are relevant snippets from my files:

pom.xml

<properties>
    <appengine.maven.plugin.version>1.3.2</appengine.maven.plugin.version>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>

    <endpoints.project.id>networking-1088</endpoints.project.id>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-bom</artifactId>
            <version>0.80.0-alpha</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>com.google.endpoints</groupId>
        <artifactId>endpoints-framework</artifactId>
        <version>2.2.1</version>
    </dependency>
    <!-- [START api_management] -->
    <dependency>
        <groupId>com.google.endpoints</groupId>
        <artifactId>endpoints-management-control-appengine-all</artifactId>
        <version>1.0.11</version>
    </dependency>
    <!-- [END api_management] -->
    <dependency>
        <groupId>com.googlecode.objectify</groupId>
        <artifactId>objectify</artifactId>
        <version>5.1.22</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>1.9.71</version>
    </dependency>
</dependencies>

<build>
    <!-- for hot reload of the web application -->
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>display-dependency-updates</goal>
                        <goal>display-plugin-updates</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <webResources>
                    <resources>
                        <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                    </resources>
                </webResources>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>${appengine.maven.plugin.version}</version>
        </plugin>
        <!-- [START endpoints_plugin] -->
        <plugin>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>endpoints-framework-maven-plugin</artifactId>
            <version>1.0.2</version>
            <configuration>
                <!-- plugin configuration -->
                <hostname>${endpoints.project.id}.appspot.com</hostname>
            </configuration>
        </plugin>
        <!-- [END endpoints_plugin] -->
    </plugins>
</build>

web.xml

<!-- Wrap the backend with Endpoints Frameworks v2. -->
<servlet>
    <servlet-name>EndpointsServlet</servlet-name>
    <servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class>
    <init-param>
        <param-name>services</param-name>
        <param-value>com.iitbaapune.app.RegistrantEndpoint</param-value>
    </init-param>
</servlet>

<!-- Route API method requests to the backend. -->
<servlet-mapping>
    <servlet-name>EndpointsServlet</servlet-name>
    <url-pattern>/_ah/api/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- [START api_management] -->
<!-- Add a filter that fetches the service config from service management. -->
<filter>
    <filter-name>endpoints-api-configuration</filter-name>
    <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
</filter>

<!-- Add a filter that performs Endpoints logging and monitoring. -->
<filter>
    <filter-name>endpoints-api-controller</filter-name>
    <filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
    <init-param>
        <param-name>endpoints.projectId</param-name>
        <param-value>${endpoints.project.id}</param-value>
    </init-param>
    <init-param>
        <param-name>endpoints.serviceName</param-name>
        <param-value>${endpoints.project.id}.appspot.com</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>endpoints-api-configuration</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>

<filter-mapping>
    <filter-name>endpoints-api-controller</filter-name>
    <servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
<!-- [END api_management] -->

appengine-web.xml

  <!-- [START env_variables] -->
<env-variables>
    <env-var name="ENDPOINTS_SERVICE_NAME" value="networking-1088.appspot.com" />
</env-variables>
<!-- [END env_variables] -->

How can I get rid of this error while retaining API management?

Price
  • 2,683
  • 3
  • 17
  • 43
  • Have you deployed your service configuration with `gcloud endpoints services deploy`? – Rose Davidson Feb 12 '19 at 21:06
  • Thanks for helping troubleshoot, Rose! Yes, I did deploy the service configurations. I see the following 4 configurations deployed: 2019-02-12r3 networking-1088.appspot.com, 2019-02-12r2 networking-1088.appspot.com, 2019-02-12r1 networking-1088.appspot.com, 2019-02-12r0 networking-1088.appspot.com – Price Feb 12 '19 at 21:21

1 Answers1

0

For what it is worth, I had the same issue. Uncommenting the endpoints-api-configuration filter, made error go away but left me without authentication support.

Eventually while rebuilding the entire project from the example provided here, I noticed that GOOGLE_APPLICATION_CREDENTIALS was the cause of my com.google.api.control.ConfigFilter doFilter: Rejecting this API request due to config loading error.

 <env-variables>
   <env-var name="ENDPOINTS_SERVICE_NAME" value="${endpoints.project.id}.appspot.com" />
   <env-var name="GOOGLE_APPLICATION_CREDENTIALS" value="WEB-INF/myproject-firebase-adminsdk-xyz.json" />
 </env-variables>

Omitting the GOOGLE_APPLICATION_CREDENTIALS line made the error go away in my case...

J.F.
  • 13,927
  • 9
  • 27
  • 65