Google app engine 使用调用数据流管道的Servlet部署GAE flexible项目时出错
我试图用JAVA部署一个AppEngine Flexible环境项目,其中只包含一个简单的Servlet,该Servlet创建一个管道,以便在每次调用服务时在GoogleDataflow中执行,但在Eclipse或Console中部署时总是遇到同样的错误。谁知道为什么会发生这种错误?请帮忙 Servlet代码:Google app engine 使用调用数据流管道的Servlet部署GAE flexible项目时出错,google-app-engine,google-cloud-platform,google-cloud-dataflow,Google App Engine,Google Cloud Platform,Google Cloud Dataflow,我试图用JAVA部署一个AppEngine Flexible环境项目,其中只包含一个简单的Servlet,该Servlet创建一个管道,以便在每次调用服务时在GoogleDataflow中执行,但在Eclipse或Console中部署时总是遇到同样的错误。谁知道为什么会发生这种错误?请帮忙 Servlet代码: import java.io.IOException; import javax.servlet.annotation.WebServlet; import javax.servlet.
import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/execute")
public class ServletPipeline extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, OutOfMemoryError {
BacktestingPipeline.execute();
}
}
管道代码:
import org.apache.beam.runners.dataflow.DataflowRunner;
import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions;
import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.apache.beam.sdk.transforms.Create;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.transforms.MapElements;
import org.apache.beam.sdk.transforms.ParDo;
import org.apache.beam.sdk.transforms.SimpleFunction;
public class BacktestingPipeline
{
public static void execute ()
{
//Create Pipeline Options for Google Cloud Dataflow
DataflowPipelineOptions options = PipelineOptionsFactory.as(DataflowPipelineOptions.class);
options.setProject("[PROJECT_ID]");
options.setTempLocation("gs://[MY_BUCKET]/temp");
options.setStagingLocation("gs://[MY_BUCKET]/staging");
options.setRunner(DataflowRunner.class);
Pipeline p = Pipeline.create(options);
p.apply(Create.of("Hello", "World"))
.apply(MapElements.via(new SimpleFunction<String, String>() {
@Override
public String apply(String input) {
return input.toUpperCase();
}
}))
.apply(ParDo.of(new DoFn<String, Void>() {
@ProcessElement
public void processElement(ProcessContext c) {
c.element();
}
}));
p.run();
}
}
我的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>
<packaging>war</packaging>
<version>0.1.0-SNAPSHOT</version>
<groupId>com.testing</groupId>
<artifactId>testing-dataflow-servlet</artifactId>
<properties>
<appengine.maven.plugin.version>1.3.1</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>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<prerequisites>
<maven>3.5</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.54</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0-b07</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xerial.snappy</groupId>
<artifactId>snappy-java</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
<build>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin.version}</version>
</plugin>
</plugins>
</build>
</project>
我在app.yaml中尝试过这个,但它不起作用
resources:
memory_gb: 2.0
health_check:
enable_health_check: False
这可能与您在doGet方法中抛出的异常有关。尝试删除它。如果servlet仍然不工作,那么它可能与您的数据流逻辑有关。也许这也可能与doGet方法中没有返回任何内容有关 我将从一开始做一个顺序测试 使用Hello World测试servlet。如果它不工作,可能是配置问题。 使用数据流逻辑测试servlet。如果它不起作用,我会用注释来测试它,除了第一行,然后是第一行和第二行,依此类推。
原始问题中的错误发生在部署过程中-没有任何代码被执行,因此它不是代码中的错误。我已经尝试了您建议的几乎所有方法。我执行了数据流逻辑,它工作了,这是一个简单的数据流“hello world”。我单独使用doGet方法部署了servlet,并且它可以工作。我读的是关于战争文件大小的东西。因为我只使用servlet部署了GAE项目,它可以工作,但是当我在没有任何数据流逻辑的情况下将数据流依赖项添加到pom.xml中,并且作为GAE灵活项目再次部署时,它就不工作了。docker容器可以完美地启动,但当服务启动时,就会失败。@jkff正是如此。问题发生在部署过程中。甚至我也试过这家伙在这里提到的一部分,关于DataflowPipelineOptions中的SetFileToStage,但它不起作用。由于错误发生在代码的部署过程中,这意味着代码根本不会执行,并且错误不是特定于数据流的,而是appengine maven插件的错误。我不熟悉它,但是如果你在谷歌上搜索appengine maven plugin non-zero exit,会有很多结果,希望其中一些会有所帮助。另外:你是否尝试过使用常规的GAE部署工具而不是maven插件部署你的应用程序?那么成功了吗?我想确定这究竟是maven插件的问题,还是您的部署配置的问题。如果您在问题中还包括了app.yaml文件,这可能会有所帮助。@jkff我在问题中添加了我的app.yaml。当你说使用常规的GAE部署工具时,你能再给我解释一下吗?我已经从Eclipse部署到appengine Flexible,而且我还尝试使用mvn clean包直接从控制台部署,然后是mvn appengine:deploy。但错误是一样的。我的意思是使用gcloud app deploy命令进行部署。maven插件似乎吞下了命令的错误输出,却没有告诉您出了什么问题?然后手动运行该命令会有所帮助,除非它位于maven输出的某个部分,而您在问题中没有包括该部分-您能检查一下吗?-我还建议在上提交一个关于这种情况下的非信息性错误输出的问题。
service: [MY_SERVICE]
runtime: java
env: flex
resources:
memory_gb: 2.0
health_check:
enable_health_check: False