mavengoogle-app-enginegcloudmaven-gae-pluginappengine-maven-plugin

Parsing error on app.yaml with AppEngine Maven plugin


I am trying to run a local (developer machine) Java AppEngine Standard Env server using the new Maven plugin (com.google.cloud.tools:appengine-maven-plugin:1.2.1) with Google Cloud SDK [148.0.1]. The command is mvn appengine:run -Dmaven.test.skip=true

When I do that, I get TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'.

  --- appengine-maven-plugin:1.2.1:run (default-cli) @ tradeos ---
Mar 28, 2017 2:18:45 PM com.google.cloud.tools.appengine.cloudsdk.CloudSdk logCommand
INFO: submitting command: C:\python27_x64\python.exe c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\bin\dev_appserver.py F:\freightos-maven\tradeos\target\tradeos-0.0.1-SNAPSHOT --dev_appserver_log_level=debug
 GCLOUD: Traceback (most recent call last):
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 101, in <module>
 GCLOUD:     _run_file(__file__, globals())
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 97, in _run_file
 GCLOUD:     execfile(_PATHS.script_file(script_name), globals_)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1041, in <module>
 GCLOUD:     main()
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1037, in main
 GCLOUD:     dev_server.stop()
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 845, in stop
 GCLOUD:     metrics.GetMetricsLogger().Stop()
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\metrics.py", line 117, in Stop
 GCLOUD:     total_run_time = int((Now() - self._start_time).total_seconds())
 GCLOUD: TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

The SDK code shows that this happens when trying to stop the metrics module after it failed to initialize. So, I edited the SDK to give hard-coded values to let the dev_appserver continue and so expose the actual error.

That's when I started getting a parsing error while reading appengine-web.xml. See below.

<<< appengine-maven-plugin:1.2.1:run (default-cli) < package @ tradeos <<<
 --- appengine-maven-plugin:1.2.1:run (default-cli) @ tradeos ---
Mar 28, 2017 12:10:34 PM com.google.cloud.tools.appengine.cloudsdk.CloudSdk logCommand
INFO: submitting command: C:\python27_x64\python.exe c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\bin\dev_appserver.py F:\freightos-maven\tradeos\target\tradeos-0.0.1-SNAPSHOT --dev_appserver_log_level=debug
 GCLOUD: Traceback (most recent call last):
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 101, in <module>
 GCLOUD:     _run_file(__file__, globals())
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 97, in _run_file
 GCLOUD:     execfile(_PATHS.script_file(script_name), globals_)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1041, in <module>
 GCLOUD:     main()
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 1029, in main
 GCLOUD:     dev_server.start(options)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 754, in start
 GCLOUD:     env_variables=parsed_env_variables)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 851, in __init__
 GCLOUD:     env_variables)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 131, in __init__
 GCLOUD:     self._config_path)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 438, in _parse_configuration
 GCLOUD:     config, files = self._parse_java_configuration(configuration_path)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\application_configuration.py", line 485, in _parse_java_configuration
 GCLOUD:     config = appinfo.LoadSingleAppInfo(app_yaml_str)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\api\appinfo.py", line 2369, in LoadSingleAppInfo
 GCLOUD:     listener.Parse(app_info)
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\api\yaml_listener.py", line 227, in Parse
 GCLOUD:     self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\api\yaml_listener.py", line 173, in _HandleEvents
 GCLOUD:     for event in events:
 GCLOUD:   File "c:\users\user\appdata\local\google\cloud sdk\google-cloud-sdk\platform\google_appengine\google\appengine\api\yaml_listener.py", line 213, in _GenerateEventParameters
 GCLOUD:     raise yaml_errors.EventListenerYAMLError(e)
 GCLOUD: google.appengine.api.yaml_errors.EventListenerYAMLError: while scanning for the next token
 GCLOUD: found character '\t' that cannot start any token
 GCLOUD:   in "<string>", line 11929, column 1:

What I tried:

pom.xml follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion><!-- REQUIRED -->

    <parent>
        <groupId>com.tradeos</groupId>
        <artifactId>freightos-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../freightos-parent/pom.xml</relativePath>
    </parent>
    <artifactId>tradeos</artifactId>
    <packaging>war</packaging><!-- REQUIRED -->

    <properties>
        <appengine.maven.plugin.version>1.2.1</appengine.maven.plugin.version>
        <gcloud.plugin.version>2.0.9.133.v201611104</gcloud.plugin.version>
        <failOnMissingWebXml>false</failOnMissingWebXml><!-- REQUIRED -->
    </properties>

    <prerequisites><!-- Optional, but suggested -->
        <maven>3.3.9</maven><!-- Recommended minimum maven version -->
    </prerequisites>

    <build>
        <!-- for hot reload of the web application-->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/java/UnitTests.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <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>
                <!-- Used to add additional sources -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>lib/gwt</source>
                                <source>lib/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--Override compiler and java version -->
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <compilerId>jdt</compilerId>
                </configuration>
                <dependencies>
                    <dependency>
                        <!-- Use java jdt compiler instead of maven java compiler(javac) -->
                        <groupId>org.eclipse.tycho</groupId>
                        <artifactId>tycho-compiler-jdt</artifactId>
                        <version>${jdt.compiler.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <!-- GWT maven plugin to do GWT compile -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>gwt-maven-plugin</artifactId>
                <version>${gwtVersion}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sourceLevel>1.7</sourceLevel>
                    <style>OBF</style>
                    <localWorkers>3</localWorkers>
                    <extraJvmArgs>-Xmx3072m</extraJvmArgs>
                    <modules>
                        <module>com.tradeos.Tradeos</module>
                    </modules>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <resource>
                            <directory>${project.basedir}/lib/libs</directory>
                            <targetPath>WEB-INF/lib</targetPath>
                            <includes>
                                <include>easypost-java-2.0.9.jar</include>
                                <include>gwt-servlet-deps.jar</include>
                                <include>org.moxieapps.gwt.highcharts-1.5.0.jar</include>
                                <include>poi-3.14-20160629.jar</include>
                                <include>gwt-visualization.jar</include>
                                <include>pdfcrowd.jar</include>
                                <include>ip2c.jar</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.maven.plugin.version}</version>
                 <configuration><!--
                    <jvmFlags>-XX:+UseG1GC -Xmx2G -XX:MaxPermSize=1G</jvmFlags>
                    <maxModuleInstances>1</maxModuleInstances>
                    <port>8888</port>
                    <startSuccessTimeout>0</startSuccessTimeout> -->
                    <devAppserverLogLevel>debug</devAppserverLogLevel>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.1.v20170120</version>
                <configuration>
                    <httpConnector>
                        <host>localhost</host>
                        <port>8888</port>
                    </httpConnector>
                    <webAppSourceDirectory>${project.build.directory}/${project.artifactId}-${project.version}</webAppSourceDirectory>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-mockito-release-full</artifactId>
            <version>1.6.4</version>
            <classifier>full</classifier>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.tradeos</groupId>
            <artifactId>pdfcrowd</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/libs/pdfcrowd.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>com.tradeos</groupId>
            <artifactId>gails</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.2</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.3.2</version>
        </dependency>

        <dependency>
            <groupId>com.allen-sauer.gwt.dnd</groupId>
            <artifactId>gwt-dnd</artifactId>
            <version>3.3.0</version>
        </dependency>

        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.8.1</version>
        </dependency>

        <dependency>
            <groupId>com.google.oauth-client</groupId>
            <artifactId>google-oauth-client</artifactId>
            <version>1.20.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.apis</groupId>
            <artifactId>google-api-services-cloudmonitoring</artifactId>
            <version>v2beta2-rev42-1.21.0</version>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.10</version>
            <scope>test</scope>
        </dependency>

        <!-- Add itextpdf java jar -->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
            <version>18.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/gwt/guava-gwt-18.0.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>net.sf.advanced-gwt</groupId>
            <artifactId>advanced-components</artifactId>
            <version>2.0.7</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/gwt/advanced-components-2.0.7.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>org.moxieapps.gwt</groupId>
            <artifactId>org.moxieapps.gwt.highcharts</artifactId>
            <version>1.5.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/libs/org.moxieapps.gwt.highcharts-1.5.0.jar</systemPath>
        </dependency>

        <!-- POI library version 3.14 modified to be compatible with appengine -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>poi-3.14-20160629</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/libs/poi-3.14-20160629.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>easypost</groupId>
            <artifactId>easypost-java</artifactId>
            <version>2.0.9</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/libs/easypost-java-2.0.9.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>gwt.servlet.deps</groupId>
            <artifactId>gwt-servlet-deps</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/libs/gwt-servlet-deps.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-maps3</artifactId>
            <version>0.1a</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/gwt/gwt-maps3-0.1a.jar</systemPath>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.19.1</version>
        </dependency>

        <dependency>
            <groupId>net.spy</groupId>
            <artifactId>spymemcached</artifactId>
            <version>2.11.6</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-servlet</artifactId>
            <version>1.19.1</version>
        </dependency>

    </dependencies>
</project>

Solution

  • In this case, tabs were coming from web.xml. That is a bug in the tool, as it should handle legal characters like this, but a workaround is to replace tabs with spaces in web.xml and appengine-web.xml.