使用Maven将Java应用程序部署到heroku失败 [英] Java app deployment to heroku using Maven failed

查看:189
本文介绍了使用Maven将Java应用程序部署到heroku失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为基于Tomcat的Java应用程序设置持续部署流程,使用Github作为源代码托管,TravisCI用于构建WAR文件,运行单元测试,然后Heroku部署打包的WAR文件。



我试着从



https://devcenter.heroku.com/articles/部署-war-files-to-heroku-from-travis-ci#创建一个java-web-application

从上述教程中运行以下步骤时出错:



mvn clean heroku:deploy-war



Command outpt:

  $ mvn -e clean heroku:deploy-war 
[INFO]打开错误堆栈跟踪。
[INFO]扫描项目...
[警告]
[警告]构建com.example的有效模型时遇到了一些问题:travis-heroku-java-example:war :0.1-SNAPSHOT
[WARNING]'build.plugins.plugin.version'for org.apache.maven.plugins:缺少maven-compiler-plugin。 @第31行第10栏
[警告]
[警告]强烈建议您修复这些问题,因为这会威胁构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式不正确的项目。
[警告]
[信息]
[信息] ----------------------------- -------------------------------------------
[信息]构建简单的Web应用程序0.1-SNAPSHOT
[INFO] ------------------------------------ ------------------------------------
[信息]
[信息] --- maven-clean-plugin:2.3:clean(default-clean)@travis-heroku-java-example ---
[信息]删除文件集:/ home / ciuser / travis-heroku-java-示例/目标(包括:[**],排除:[])
[信息]
[信息]>>> heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku-java-example>>>
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources(default-resources)@travis-heroku-java-example ---
[WARNING] Using平台编码(实际上是UTF-8)来复制过滤资源,即构建依赖于平台!
[INFO]跳过不存在的资源目录/ home / ciuser / travis-heroku -java -sample / src / main / resources
[信息]
[信息] --- maven-compiler-插件:2.0.2:编译(默认编译)@travis-heroku-java-example ---
[INFO]编译1个源文件到/ home / ciuser / travis-heroku -java-example / target / class
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources(default-testResources)@travis-heroku-java-example ---
[警告]使用平台编码(实际上是UTF-8)来复制已过滤的资源,即构建依赖于平台!
[INFO]跳过不存在的资源目录/ home / ciuser / travis-heroku -java -sample / src / test / resources
[信息]
[信息] --- maven-compiler-插件:2.0.2:testCompile(default-testCompile)@travis-heroku-java-example ---
[INFO]没有源编译
[信息]
[信息] - - maven-surefire-plugin:2.10:测试(默认测试)@travis-heroku-java-example ---
[信息]没有测试运行。
[INFO] Surefire报告目录:/ home / ciuser / travis-heroku-java-example / target / surefire-reports

------------- ------------------------------------------
测试
------------------------------------------------- ------

结果:

测试运行:0,失败:0,错误:0,跳过:0

[INFO ]
[INFO] --- maven-war-plugin:2.1.1:war(default-war)@travis-heroku-java-example ---
[INFO]打包webapp
[INFO]在[/ home / ciuser / travis-heroku-java-example / target / travis-heroku-java-example]中组装webapp [travis-heroku-java-example]
[INFO] Processing war project
[INFO]复制webapp资源[/ home / ciuser / travis-heroku-java-example / src / main / webapp]
[INFO]在[86 msecs]中汇编的Webapp
[INFO ]构建战争:/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[信息] WEB-INF / web.xml已添加,跳过
[INFO]
[信息]<<< heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku -java-example<<<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku -java-example ---
[INFO]配置工件:com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO]将webapp-runner-7.0.57.2.jar复制到/ home / ciuser / travis-heroku-java-例子/ target / dependency / webapp-runner.jar
[INFO] --->包装应用程序...
[信息] - 应用程序:拥有 - 公墓 - 7933
[信息] - 包括:目标/依赖项/ webapp-runner.jar
[信息] - 包括:目标/travis-heroku-java-example.war
[INFO] --------------------------------- ---------------------------------------
[INFO] BUILD FAILURE
[INFO] --------------------------------------------- ---------------------------
[信息]总时间:10.636s
[信息]完成日期:星期五Apr 24 03:33:35 UTC 2015
[INFO] Final Memory:19M / 46M
[INFO] --------------------- -------------------------------------------------- -
[**错误]无法执行目标com.heroku.sdk:heroku-maven-plugin:0.3.6:项目中的deploy-war(default-cli)travis-heroku-java-example:失败部署应用程序:禁止 - > [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标com.heroku.sdk:heroku-maven-plugin:0.3.6:项目中的deploy-war(default-cli)travis- heroku-java-example:无法部署应用程序**
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
在org.apache.maven.lifecycle。 internal.MojoExecutor.execute(MojoExecutor.java:153)
在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
在org.apache.maven.lifecycle。 internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
位于org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
位于org.apache.maven.lifecycle。 internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apa che.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli。执行(MavenCli.java:537)
在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
在org.apache.maven.cli.MavenCli.main(MavenCli。在sun.reflect.NativeMethodAccessorImpl.invoke0(本地方法)
$ sunfr.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
$ b $在sun.reflect.DelegatingMethodAccessorImpl。 invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher。 java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher。 java:409)$ or $ $ $ b $ org.c odehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
导致:org.apache.maven.plugin.MojoFailureException:无法在com.heroku.sdk上部署应用程序
。 maven.DeployWarMojo.execute(DeployWarMojo.java:24)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal。 MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
引起:org.apache.http.client.HttpResponseException:在com.heroku.sdk.deploy中禁止
。 RestClient.handleResponse(RestClient.java:87)
at com.heroku.sdk.deploy.RestClient.get(RestClient.java:26)
at com.heroku.sdk.deploy.ConfigVars.getConfigVars( ConfigVars.java:39)
at com.heroku.sdk.deploy.ConfigVars.merge(ConfigVars.java:22)
at com.heroku.sdk.deploy.App.mergeConfigVars(App.java: 152)
at com.heroku.sdk.deploy.App.deploy(App.java:81)
at com.heroku.sdk.deploy.App.deploy(App.java:87)
at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:29)
at com .heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:20)
... 21 more
[错误]
[错误]使用-X开关重新运行Maven以启用完整的调试日志。
[错误]
[错误]有关错误和可能解决方案的更多信息,请阅读以下文章:
[错误] [帮助1] http://cwiki.apache.org / confluence / display / MAVEN / MojoFailureException
$

上述错误讯息输出:
$ b

  [**错误]无法执行目标com.heroku.sdk:heroku-maven-plugin :0.3.6:项目中的deploy-war(default-cli)travis-heroku-java-example:部署应用程序失败:Forbidden  - > [Help 1] 

以下是Maven系统配置:

  $ mvn -version 
Apache Maven 3.0.4
Maven home:/ usr / share / maven
Java版本:1.7.0_80,供应商:Oracle Corporation
Java home:/ usr / lib / jvm / java-7-oracle / jre
默认语言环境:en_US,平台编码:UTF-8
操作系统名称:linux,版本:3.2.0-79-generic,arch:amd64,family:unix

Java版本是:
$ b

  $ java -version 
Java版本1.7.0_80
Java™SE运行时环境(build 1.7.0_80-b15)
Java HotSpot™64位服务器虚拟机(build 24.80-b11,混合模式)
$

Pom文件:

 <?xml version =1.0encoding =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/maven-v4_0_0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> com.example< / groupId>
< artifactId> travis-heroku-java-example< / artifactId>
< version> 0.1-SNAPSHOT< / version>
<包装>战争< / packaging>
<名称>简单网页应用程式< / name>

<依赖关系>
< dependency>
< groupId> org.apache.geronimo.specs< / groupId>
< artifactId> geronimo-servlet_2.4_spec< / artifactId>
< version> 1.1.1< / version>
< /依赖关系>
< /依赖关系>

< pluginRepositories>
< pluginRepository>
< id> ruby​​gems-releases< / id>
< url> http://rubygems-proxy.torquebox.org/releases< / url>
< / pluginRepository>
< / pluginRepositories>

< build>
< finalName> travis-heroku-java-example< / finalName>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
<配置>
< source> 1.7< / source>
< target> 1.7< / target>
< / configuration>
< / plugin>
< plugin>
< groupId> com.heroku.sdk< / groupId>
< artifactId> heroku-maven-plugin< / artifactId>
< version> 0.3.6< / version>
<配置>
< appName>拥有 - 公墓-7933< / appName>
< / configuration>
< / plugin>
< / plugins>

< pluginManagement>
< plugins>
< plugin>
< groupId> com.heroku.sdk< / groupId>
< artifactId> heroku-maven-plugin< / artifactId>
< version> 0.3.6< / version>
<配置>
< appName> boiling-beach-1111< / appName>
< / configuration>
< / plugin>
< plugin>
< groupId> de.saumya.mojo< / groupId>
< artifactId> gem-maven-plugin< / artifactId>
< version> 1.0.5< / version>
<配置>
< execArgLines>
< execArgLine> $ {project.build.directory} / ruby​​gems / bin / travis< / execArgLine>
< execArgLine>加密< / execArgLine>
< execArgLine> HEROKU_API_KEY = $ {herokuApiKey}< / execArgLine>
< / execArgLines>
< / configuration>
<依赖关系>
< dependency>
< groupId> ruby​​gems< / groupId>
< artifactId> travis< / artifactId>
< version> 1.7.1< / version>
< type> gem< / type>
< /依赖关系>
< dependency>
< groupId> ruby​​gems< / groupId>
< artifactId> pry< / artifactId>
< version> 0.9.12.6< / version>
< type> gem< / type>
< /依赖关系>
< /依赖关系>
< / plugin>
< / plugins>
< / pluginManagement>

< / build>
< / project>


解决方案

我发现问题是什么!!!



Heroku deploy-war maven插件在使用3.0.X版本时需要Maven 3.2.X版本。



已安装我的ubuntu机器上的Maven 3.2.1版本以及war文件已成功部署到Heroku。

我从Github Heroku Maven插件库中了解了这一点Readme文件:
Maven 3.2.x
Java 1.7或更高版本

$ $ $ code>

谢谢@为您节省时间。

输出:

  $ maven -version 
Apache Maven 3.2.1(ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52 + 00:00 )
Maven home:/ usr / share / maven3
Java版本:1.7.0_80,供应商:Oracle Corporation
Java home:/ usr / lib / jvm / java-7-oracle / jre
默认语言环境:en_US,平台编码:UTF-8
操作系统名称:linux,版本:3.2.0-79-generic,arch:amd64, family:unix
$
$
$
$ maven -e clean heroku:deploy-war
[INFO]错误堆栈跟踪已打开。
[INFO]扫描项目...
[警告]
[警告]构建com.example的有效模型时遇到了一些问题:travis-heroku-java-example:war :0.1-SNAPSHOT
[WARNING]'build.plugins.plugin.version'for org.apache.maven.plugins:缺少maven-compiler-plugin。 @第31行第11栏
[警告]
[警告]强烈建议修复这些问题,因为它们威胁到构建的稳定性。
[警告]
[警告]出于这个原因,未来的Maven版本可能不再支持构建这种格式不正确的项目。
[警告]
[信息]
[信息]使用线程数为1
的构建器org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder [ INFO]
[信息] ----------------------------------------- -------------------------------
[INFO]构建简单的Web应用程序0.1-SNAPSHOT
[ INFO] ------------------------------------------------ ------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (默认清洁)@ travis-heroku -java-example ---
[INFO]删除/ home / ciuser / travis-heroku -java-example / target
[INFO]
[ INFO]>>> heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku-java-example>>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources(default-resources)@travis-heroku-java-example ---
[WARNING] Using平台编码(实际上是UTF-8)来复制过滤资源,即构建依赖于平台!
[INFO]跳过不存在的资源目录/ home / ciuser / travis-heroku -java -sample / src / main / resources
[信息]
[信息] --- maven-compiler-插件:2.5.1:编译(默认编译)@travis-heroku-java-example ---
[警告]文件编码尚未设置,使用平台编码UTF-8,即构建依赖于平台!
[INFO]编译1个源文件到/ home / ciuser / travis-heroku-java-example / target / classes
[信息]
[信息] --- maven-resources-plugin :2.6:testResources(default-testResources)@travis-heroku-java-example ---
[警告]使用平台编码(实际上是UTF-8)来复制已过滤的资源,即构建依赖于平台!
[INFO]跳过不存在的资源目录/ home / ciuser / travis-heroku -java -sample / src / test / resources
[信息]
[信息] --- maven-compiler-插件:2.5.1:testCompile(default-testCompile)@travis-heroku-java-example ---
[INFO]没有资源可以编译
[信息]
[信息] - - maven-surefire-plugin:2.12.4:测试(默认测试)@travis-heroku-java-example ---
[信息]没有测试运行。
[INFO]
[INFO] --- maven-war-plugin:2.2:war(default-war)@travis-heroku-java-example ---
[INFO] Packaging webapp
[INFO]在[/ home / ciuser / travis-heroku-java-example / target / travis-heroku-java-example]中组装webapp [travis-heroku-java-example]
[INFO] ]处理war项目
[INFO]复制webapp资源[/ home / ciuser / travis-heroku-java-example / src / main / webapp]
[INFO] Webapp在[38 msecs]中汇编
[INFO]构建战争:/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[INFO] WEB-INF / web.xml已添加,跳过
[信息]
[信息]<<< heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku -java-example<<<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war(default-cli)@travis-heroku -java-example ---
[INFO]配置工件:com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO]将webapp-runner-7.0.57.2.jar复制到/ home / ciuser / travis-heroku-java-例子/ target / dependency / webapp-runner.jar
[INFO] --->包装应用程序...
[信息] - 应用程序:沸腾海滩1111
[信息] - 包括:目标/依赖项/ webapp-runner.jar
[信息] - 包括:目标/travis-heroku-java-example.war
[INFO] - 正在安装:OpenJDK 1.8
[INFO] --->创建slug ...
[INFO] - file:target / heroku / slug.tgz
[INFO] - size:56MB
[INFO] --->上传slug ...
[INFO] - stack:cedar-14
[INFO] - 进程类型:[web]
[INFO] --->正在发布...
[信息] - 版本:6
[信息] ---------------------------- --------------------------------------------
[INFO ]建立成功
[信息] ---------------------------------------- --------------------------------
[信息]总时间:32.265 s
[信息]完成于:2015-04-24T20:05:46 + 00:00
[INFO] Final Memory:19M / 48M
[INFO] ------------- -------------------------------------------------- ---------


I am trying to setup the Continuous deployment process for a Tomcat based java app using Github for source code hosting, TravisCI for building the WAR file, running the unit tests and then Heroku to deploy the packaged WAR file.

I tried following the tutorial from

https://devcenter.heroku.com/articles/deploying-war-files-to-heroku-from-travis-ci#creating-a-java-web-application

I am getting an error while running the below step from the above tutorial:

mvn clean heroku:deploy-war

Command outpt:

$ mvn -e clean heroku:deploy-war
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example:travis-heroku-java-example:war:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 31, column 10
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Web Application 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.3:clean (default-clean) @ travis-heroku-java-example ---
[INFO] Deleting file set: /home/ciuser/travis-heroku-java-example/target (included: [**], excluded: [])
[INFO]
[INFO] >>> heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example >>>
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) @ travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ travis-heroku-java-example ---
[INFO] Compiling 1 source file to /home/ciuser/travis-heroku-java-example/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) @ travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ travis-heroku-java-example ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ travis-heroku-java-example ---
[INFO] No tests to run.
[INFO] Surefire report directory: /home/ciuser/travis-heroku-java-example/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

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

[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ travis-heroku-java-example ---
[INFO] Packaging webapp
[INFO] Assembling webapp [travis-heroku-java-example] in [/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ciuser/travis-heroku-java-example/src/main/webapp]
[INFO] Webapp assembled in [86 msecs]
[INFO] Building war: /home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example <<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example ---
[INFO] Configured Artifact: com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO] Copying webapp-runner-7.0.57.2.jar to /home/ciuser/travis-heroku-java-example/target/dependency/webapp-runner.jar
[INFO] ---> Packaging application...
[INFO]      - app: possessed-cemetery-7933
[INFO]      - including: target/dependency/webapp-runner.jar
[INFO]      - including: target/travis-heroku-java-example.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.636s
[INFO] Finished at: Fri Apr 24 03:33:35 UTC 2015
[INFO] Final Memory: 19M/46M
[INFO] ------------------------------------------------------------------------
[**ERROR] Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application: Forbidden -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application**
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to deploy application
        at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:24)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: org.apache.http.client.HttpResponseException: Forbidden
        at com.heroku.sdk.deploy.RestClient.handleResponse(RestClient.java:87)
        at com.heroku.sdk.deploy.RestClient.get(RestClient.java:26)
        at com.heroku.sdk.deploy.ConfigVars.getConfigVars(ConfigVars.java:39)
        at com.heroku.sdk.deploy.ConfigVars.merge(ConfigVars.java:22)
        at com.heroku.sdk.deploy.App.mergeConfigVars(App.java:152)
        at com.heroku.sdk.deploy.App.deploy(App.java:81)
        at com.heroku.sdk.deploy.App.deploy(App.java:87)
        at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:29)
        at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:20)
        ... 21 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
$

Error Message in the above output:

[**ERROR] Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.6:deploy-war (default-cli) on project travis-heroku-java-example: Failed to deploy application: Forbidden -> [Help 1]

Here is the Maven System configuration:

$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-79-generic", arch: "amd64", family: "unix"

Java Version is:

$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
$

Pom file:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>travis-heroku-java-example</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>Simple Web Application</name>

  <dependencies>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-servlet_2.4_spec</artifactId>
      <version>1.1.1</version>
    </dependency>
  </dependencies>

  <pluginRepositories>
    <pluginRepository>
      <id>rubygems-releases</id>
      <url>http://rubygems-proxy.torquebox.org/releases</url>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <finalName>travis-heroku-java-example</finalName>
    <plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.heroku.sdk</groupId>
        <artifactId>heroku-maven-plugin</artifactId>
        <version>0.3.6</version>
        <configuration>
          <appName>possessed-cemetery-7933</appName>
        </configuration>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
      <plugin>
          <groupId>com.heroku.sdk</groupId>
          <artifactId>heroku-maven-plugin</artifactId>
          <version>0.3.6</version>
          <configuration>
            <appName>boiling-beach-1111</appName>
          </configuration>
        </plugin>
        <plugin>
          <groupId>de.saumya.mojo</groupId>
          <artifactId>gem-maven-plugin</artifactId>
          <version>1.0.5</version>
          <configuration>
            <execArgLines>
              <execArgLine>${project.build.directory}/rubygems/bin/travis</execArgLine>
              <execArgLine>encrypt</execArgLine>
              <execArgLine>HEROKU_API_KEY=${herokuApiKey}</execArgLine>
            </execArgLines>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>rubygems</groupId>
              <artifactId>travis</artifactId>
              <version>1.7.1</version>
              <type>gem</type>
            </dependency>
            <dependency>
              <groupId>rubygems</groupId>
              <artifactId>pry</artifactId>
              <version>0.9.12.6</version>
              <type>gem</type>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>

  </build>
</project>

解决方案

I found what the issue was!!!

Heroku deploy-war maven plugin requires Maven 3.2.X version while I was using 3.0.X version.

Installed Maven 3.2.1 version on my ubuntu machine and the war file was successfully deployed to Heroku.

I got to know this from Github Heroku Maven plugin repository Readme file:

Requirements

Maven 3.2.x
Java 1.7 or higher

Thank you @Steve for your time.

Output:

$ maven -version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
Maven home: /usr/share/maven3
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-79-generic", arch: "amd64", family: "unix"
$
$
$
$ maven -e clean heroku:deploy-war
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.example:travis-heroku-java-example:war:0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 31, column 11
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple Web Application 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ travis-heroku-java-example ---
[INFO] Deleting /home/ciuser/travis-heroku-java-example/target
[INFO]
[INFO] >>> heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ travis-heroku-java-example ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /home/ciuser/travis-heroku-java-example/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ travis-heroku-java-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ciuser/travis-heroku-java-example/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ travis-heroku-java-example ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ travis-heroku-java-example ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ travis-heroku-java-example ---
[INFO] Packaging webapp
[INFO] Assembling webapp [travis-heroku-java-example] in [/home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ciuser/travis-heroku-java-example/src/main/webapp]
[INFO] Webapp assembled in [38 msecs]
[INFO] Building war: /home/ciuser/travis-heroku-java-example/target/travis-heroku-java-example.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example <<<
[INFO]
[INFO] --- heroku-maven-plugin:0.3.6:deploy-war (default-cli) @ travis-heroku-java-example ---
[INFO] Configured Artifact: com.github.jsimone:webapp-runner:7.0.57.2:jar
[INFO] Copying webapp-runner-7.0.57.2.jar to /home/ciuser/travis-heroku-java-example/target/dependency/webapp-runner.jar
[INFO] ---> Packaging application...
[INFO]      - app: boiling-beach-1111
[INFO]      - including: target/dependency/webapp-runner.jar
[INFO]      - including: target/travis-heroku-java-example.war
[INFO]      - installing: OpenJDK 1.8
[INFO] ---> Creating slug...
[INFO]      - file: target/heroku/slug.tgz
[INFO]      - size: 56MB
[INFO] ---> Uploading slug...
[INFO]      - stack: cedar-14
[INFO]      - process types: [web]
[INFO] ---> Releasing...
[INFO]      - version: 6
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.265 s
[INFO] Finished at: 2015-04-24T20:05:46+00:00
[INFO] Final Memory: 19M/48M
[INFO] ------------------------------------------------------------------------

这篇关于使用Maven将Java应用程序部署到heroku失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆