我正在尝试使用com.google.cloud.tools:appengine-maven-plugin:1.2.1
带有 Google Cloud SDK [148.0.1] 的新 Maven 插件 () 运行本地(开发人员机器)Java AppEngine 标准环境服务器。命令是mvn appengine:run -Dmaven.test.skip=true
当我这样做时,我得到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'
SDK 代码显示,在初始化失败后尝试停止指标模块时会发生这种情况。因此,我编辑了 SDK 以提供硬编码值以让 dev_appserver 继续运行,从而暴露实际错误。
那是我在阅读时开始遇到解析错误的时候appengine-web.xml
。见下文。
<<< 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:
我尝试了什么:
- 旧版本的 Maven 插件 (1.0.0)。相同的结果
- 我下载了示例应用留言簿并尝试运行它,它运行良好。我的应用程序与示例具有相同的结构。
appengine-web.xml
将示例中的复制到我的项目中,仍然是相同的错误。- 服务器与 Java SDK 一起提供的旧 Maven 插件工作正常
com.google.appengine:com.google.appengine:1.9.50
pom.xml
如下:
<?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>