jjzjj

java - 部署到 Google App Engine

coder 2024-03-07 原文

我正在为 Google App Engine 苦苦挣扎。我想要做的就是:

我正在按照教程的确切步骤进行操作。我已经试过好几次了。该应用程序在 Jenkins 中构建良好(我设法使其运行)但部署失败。

+ gcloud --project=MyProject preview app deploy target/guestbook-1.0-SNAPSHOT.war
ERROR: File [/var/jenkins/workspace/MyProject/target/guestbook-1.0-SNAPSHOT.war] is not a valid deployable item.
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration: 
Build step 'Execute shell' marked build as failure
Finished: FAILURE

在本地开发网络服务器上一切正常。 MyProject 是项目 ID(我只是为示例更改了它)。我究竟做错了什么。我的意思是我忘记做某事了吗?我从事 Java 已经五年多了,我不明白为什么做这么基础的事情会这么难。请帮助我

来自 Jenkins :

Started by user User Name
Building remotely on cloud-dev-java in workspace /var/jenkins/workspace/MyGuestbook
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://source.developers.google.com/p/MyProject # timeout=10
Fetching upstream changes from https://source.developers.google.com/p/MyProject
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.helper store --file=/tmp/git7191806817673001841.credentials # timeout=10
 > git fetch --tags --progress https://source.developers.google.com/p/MyProject +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 2bf8419a93275dc87adb7be00d1fda9e6efc773b (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 2bf8419a93275dc87adb7be00d1fda9e6efc773b
 > git rev-list 9d2cd477ad8fcb6f210bd2418e8f708e5c5167f9 # timeout=10
[MyGuestbook] $ mvn clean test package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myapp ---
[INFO] Deleting /var/jenkins/workspace/MyGuestbook/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/MyGuestbook/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT/WEB-INF/classes
[INFO] 
[INFO] --- versions-maven-plugin:2.1:display-dependency-updates (default) @ myapp ---
[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   com.google.appengine:appengine-api-1.0-sdk ......... 1.9.17 -> 1.9.17a
[INFO]   com.google.appengine:appengine-api-stubs ........... 1.9.17 -> 1.9.17a
[INFO]   com.google.appengine:appengine-testing ............. 1.9.17 -> 1.9.17a
[INFO]   javax.servlet:servlet-api ......................... 2.5 -> 3.0-alpha-1
[INFO]   junit:junit ...................................... 4.12-beta-1 -> 4.12
[INFO]   org.mockito:mockito-all ............................. 1.9.5 -> 1.10.17
[INFO] 
[INFO] 
[INFO] --- versions-maven-plugin:2.1:display-plugin-updates (default) @ myapp ---
[INFO] 
[INFO] The following plugin updates are available:
[INFO]   com.google.appengine:appengine-maven-plugin ....... 1.9.17 -> 1.9.17a
[INFO]   maven-compiler-plugin .................................... 3.1 -> 3.2
[INFO]   maven-war-plugin ......................................... 2.4 -> 2.5
[INFO] 
[WARNING] The following plugins do not have their version specified:
[WARNING]   maven-clean-plugin ........................ (from super-pom) 2.6.1
[WARNING]   maven-deploy-plugin ....................... (from super-pom) 2.8.2
[WARNING]   maven-install-plugin ...................... (from super-pom) 2.5.2
[WARNING]   maven-resources-plugin ...................... (from super-pom) 2.7
[WARNING]   maven-site-plugin ........................... (from super-pom) 3.4
[WARNING]   maven-surefire-plugin ...................... (from super-pom) 2.18
[INFO] 
[INFO] Project defines minimum Maven version as: 3.1.0
[INFO] Plugins require minimum Maven version of: 3.1.0
[INFO] Note: the super-pom from Maven 3.1.0 defines some of the plugin
[INFO]       versions and may be influencing the plugins required minimum Maven
[INFO]       version.
[INFO] 
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO] 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/MyGuestbook/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /var/jenkins/workspace/MyGuestbook/target/test-classes
[WARNING] /var/jenkins/workspace/MyGuestbook/src/test/java/com/mycompany/myapp/GuestbookServletTest.java: Some input files use or override a deprecated API.
[WARNING] /var/jenkins/workspace/MyGuestbook/src/test/java/com/mycompany/myapp/GuestbookServletTest.java: Recompile with -Xlint:deprecation for details.
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myapp ---
[INFO] Surefire report directory: /var/jenkins/workspace/MyGuestbook/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.mycompany.myapp.GuestbookServletTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.702 sec
Running com.mycompany.myapp.SignGuestbookServletTest
Dec 22, 2014 5:32:44 PM com.google.appengine.api.datastore.dev.LocalDatastoreService init
INFO: Local Datastore initialized: 
    Type: Master/Slave
    Storage: In-memory
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.456 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/MyGuestbook/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- versions-maven-plugin:2.1:display-dependency-updates (default) @ myapp ---
[INFO] The following dependencies in Dependencies have newer versions:
[INFO]   com.google.appengine:appengine-api-1.0-sdk ......... 1.9.17 -> 1.9.17a
[INFO]   com.google.appengine:appengine-api-stubs ........... 1.9.17 -> 1.9.17a
[INFO]   com.google.appengine:appengine-testing ............. 1.9.17 -> 1.9.17a
[INFO]   javax.servlet:servlet-api ......................... 2.5 -> 3.0-alpha-1
[INFO]   junit:junit ...................................... 4.12-beta-1 -> 4.12
[INFO]   org.mockito:mockito-all ............................. 1.9.5 -> 1.10.17
[INFO] 
[INFO] 
[INFO] --- versions-maven-plugin:2.1:display-plugin-updates (default) @ myapp ---
[INFO] 
[INFO] The following plugin updates are available:
[INFO]   com.google.appengine:appengine-maven-plugin ....... 1.9.17 -> 1.9.17a
[INFO]   maven-compiler-plugin .................................... 3.1 -> 3.2
[INFO]   maven-war-plugin ......................................... 2.4 -> 2.5
[INFO] 
[WARNING] The following plugins do not have their version specified:
[WARNING]   maven-clean-plugin ........................ (from super-pom) 2.6.1
[WARNING]   maven-deploy-plugin ....................... (from super-pom) 2.8.2
[WARNING]   maven-install-plugin ...................... (from super-pom) 2.5.2
[WARNING]   maven-resources-plugin ...................... (from super-pom) 2.7
[WARNING]   maven-site-plugin ........................... (from super-pom) 3.4
[WARNING]   maven-surefire-plugin ...................... (from super-pom) 2.18
[INFO] 
[INFO] Project defines minimum Maven version as: 3.1.0
[INFO] Plugins require minimum Maven version of: 3.1.0
[INFO] Note: the super-pom from Maven 3.1.0 defines some of the plugin
[INFO]       versions and may be influencing the plugins required minimum Maven
[INFO]       version.
[INFO] 
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO] 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/MyGuestbook/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ myapp ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] 
[INFO] --- maven-war-plugin:2.4:war (default-war) @ myapp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [myapp] in [/var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp webResources [/var/jenkins/workspace/MyGuestbook/src/main/webapp/WEB-INF] to [/var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT]
[INFO] Copying webapp resources [/var/jenkins/workspace/MyGuestbook/src/main/webapp]
[INFO] Webapp assembled in [154 msecs]
[INFO] Building war: /var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.355s
[INFO] Finished at: Mon Dec 22 17:32:47 UTC 2014
[INFO] Final Memory: 20M/56M
[INFO] ------------------------------------------------------------------------
[MyGuestbook] $ /bin/sh -xe /tmp/hudson5523568617447680772.sh
+ gcloud --project=MyProject preview app deploy target/myapp-1.0-SNAPSHOT.war
ERROR: File [/var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT.war] is not a valid deployable item.
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration: 
Build step 'Execute shell' marked build as failure
Finished: FAILURE

appengine-web.xml:

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>MyProject</application>
    <version>${appengine.app.version}</version>
    <threadsafe>true</threadsafe>

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
</appengine-web-app>

我做错了什么,我错过了什么吗?我完全按照他们说的去做了。

我尝试使用 Google Source 作为存储库和 Github。什么都不管用。

编辑:

有效:

Updating module [default] from file [/tmp/appcfgpyASfUun/app.yaml]
09:15 PM Host: appengine.google.com
09:15 PM Application: esoteric-cab-803; version: 1
09:15 PM 
Starting update of app: esoteric-cab-803, version: 1
09:15 PM Getting current resource limits.
09:15 PM Scanning files on local disk.
09:15 PM Cloning 6 application files.
09:15 PM Uploading 3 files and blobs.
09:15 PM Uploaded 3 files and blobs.
09:15 PM Compilation starting.
09:15 PM Compilation completed.
09:15 PM Starting deployment.
09:15 PM Checking if deployment succeeded.
09:15 PM Deployment successful.
09:15 PM Checking if updated app version is serving.
09:15 PM Completed update of app: esoteric-cab-803, version: 1
Finished: SUCCESS

多么美妙的景象!

最佳答案

部署失败,因为您的 jenkins 构建脚本失败了:

构建步骤“Execute shell”将构建标记为失败

在“执行 shell”步骤中,您必须确保脚本以状态 0 返回。任何其他情况都被视为失败。 See this SO answer to a similar issue .

看来您的“执行 shell”部分是这个:

[MyGuestbook] $ /bin/sh -xe /tmp/hudson5523568617447680772.sh
+ gcloud --project=MyProject preview app deploy target/myapp-1.0-SNAPSHOT.war
ERROR: File [/var/jenkins/workspace/MyGuestbook/target/myapp-1.0-SNAPSHOT.war] is not a valid deployable item.
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration: 
Build step 'Execute shell' marked build as failure
Finished: FAILURE

构建的“执行 shell”部分失败,因为从脚本返回的状态代码似乎是从 gcloud 命令返回的状态代码。如果您查看文档 here, you can see that it doesn't accept .war archives, but only unpacked war folders .您可以简单地从

更改行
gcloud --project=MyProject preview app deploy target/myapp-1.0-SNAPSHOT.war

gcloud --project=MyProject preview app deploy target/myapp-1.0-SNAPSHOT

此时,构建的“执行 shell”部分将正常运行,因此整个 jenkins 构建应该正确完成。

渐变

如果您使用 gradle 进行构建,它可能已经生成了一个分解的应用程序目录:

build/exploded-app

关于java - 部署到 Google App Engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27585435/

有关java - 部署到 Google App Engine的更多相关文章

  1. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  2. ruby-on-rails - 每次我尝试部署时,我都会得到 - (gcloud.preview.app.deploy) 错误响应 : [4] DEADLINE_EXCEEDED - 2

    我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie

  3. java - 从 JRuby 调用 Java 类的问题 - 2

    我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www

  4. java - 我的模型类或其他类中应该有逻辑吗 - 2

    我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我

  5. java - 什么相当于 ruby​​ 的 rack 或 python 的 Java wsgi? - 2

    什么是ruby​​的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht

  6. ruby-on-rails - Ruby on Rails 可以部署在 Azure 网站上吗? - 2

    我可以在Azure网站上部署RubyonRails吗? 最佳答案 还没有。目前仅支持.NET和PHP。 关于ruby-on-rails-RubyonRails可以部署在Azure网站上吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/12964010/

  7. Observability:从零开始创建 Java 微服务并监控它 (二) - 2

    这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/

  8. 【Java 面试合集】HashMap中为什么引入红黑树,而不是AVL树呢 - 2

    HashMap中为什么引入红黑树,而不是AVL树呢1.概述开始学习这个知识点之前我们需要知道,在JDK1.8以及之前,针对HashMap有什么不同。JDK1.7的时候,HashMap的底层实现是数组+链表JDK1.8的时候,HashMap的底层实现是数组+链表+红黑树我们要思考一个问题,为什么要从链表转为红黑树呢。首先先让我们了解下链表有什么不好???2.链表上述的截图其实就是链表的结构,我们来看下链表的增删改查的时间复杂度增:因为链表不是线性结构,所以每次添加的时候,只需要移动一个节点,所以可以理解为复杂度是N(1)删:算法时间复杂度跟增保持一致查:既然是非线性结构,所以查询某一个节点的时候

  9. jenkins部署1--jenkins+gitee持续集成 - 2

    前置步骤我们都操作完了,这篇开始介绍jenkins的集成。话不多说,看操作1、登录进入jenkins后会让你选择安装插件,选择第一个默认的就行。安装完成后设置账号密码,重新登录。2、配置JDK和Git都需要执行路径,所以需要先把执行路径找到,先进入服务器的docker容器,2.1JDK的路径root@69eef9ee86cf:/usr/bin#echo$JAVA_HOME/usr/local/openjdk-82.2Git的路径root@69eef9ee86cf:/#whichgit/usr/bin/git3、先配置JDK和Git。点击:ManageJenkins>>GlobalToolCon

  10. 深度学习部署:Windows安装pycocotools报错解决方法 - 2

    深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal

随机推荐