无法在heroku上部署战争

时间:2015-01-16 16:55:20

标签: scala maven heroku maven-3

尝试将战争部署到heroku 使用maven 3.2.5

mvn clean heroku:deploy-war

获得此例外:

[ERROR] Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.0:deploy-war (default-cli) on project MyApp: Failed to deploy application: There was an exception invoking the remote service: HTTP(404): https://api.heroku.com/apps/MyApp/config-vars -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.heroku.sdk:heroku-maven-plugin:0.3.0:deploy-war (default-cli) on project MyApp: Failed to deploy application
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    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:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    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:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to deploy application
    at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:58)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: com.heroku.sdk.deploy.Curl$CurlException: There was an exception invoking the remote service: HTTP(404)
    at com.heroku.sdk.deploy.Curl.handleResponse(Curl.java:94)
    at com.heroku.sdk.deploy.Curl.get(Curl.java:22)
    at com.heroku.sdk.deploy.App.getConfigVars(App.java:139)
    at com.heroku.sdk.deploy.App.deploy(App.java:77)
    at com.heroku.sdk.deploy.App.deploy(App.java:93)
    at com.heroku.sdk.deploy.WarApp.deploy(WarApp.java:38)
    at com.heroku.sdk.maven.DeployWarMojo.execute(DeployWarMojo.java:54)
    ... 21 more
Caused by: java.io.FileNotFoundException: https://api.heroku.com/apps/MyApp/config-vars
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1624)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at com.heroku.sdk.deploy.Curl.handleResponse(Curl.java:90)
    ... 27 more

这就是我的pom的样子:

<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.avi</groupId>
    <artifactId>MyApp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <description>My GoTickets Web App</description>
    <inceptionYear>2014</inceptionYear>
    <properties>
        <scala.version>2.11.4</scala.version>
        <spray.version>1.3.1</spray.version>
        <akka.version>2.3.8</akka.version>
    </properties>

    <repositories>
        <repository>
            <id>scala-tools.org</id>
            <name>Scala-Tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>scala-tools.org</id>
            <name>Scala-Tools Maven2 Repository</name>
            <url>http://scala-tools.org/repo-releases</url>
        </pluginRepository>

    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <scope>test</scope>
            <groupId>org.specs2</groupId>
            <artifactId>specs2-core_2.11</artifactId>
            <version>2.4.15</version>
        </dependency>
        <dependency>
            <scope>test</scope>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-testkit_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_2.11</artifactId>
            <version>2.2.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.spray</groupId>
            <artifactId>spray-can</artifactId>
            <version>${spray.version}</version>
        </dependency>
        <dependency>
            <groupId>io.spray</groupId>
            <artifactId>spray-routing</artifactId>
            <version>${spray.version}</version>
        </dependency>
        <dependency>
            <groupId>io.spray</groupId>
            <artifactId>spray-json_2.11</artifactId>
            <version>${spray.version}</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-slf4j_2.11</artifactId>
            <version>${akka.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.5</version>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>src/main/scala</sourceDirectory>
        <testSourceDirectory>src/test/scala</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scalaVersion>${scala.version}</scalaVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.heroku.sdk</groupId>
                <artifactId>heroku-maven-plugin</artifactId>
                <version>0.3.0</version>
                <configuration>
                    <appName>MyApp</appName>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

1 个答案:

答案 0 :(得分:2)

Heroku appName配置中的plugin不正确。 Heroku应用程序必须以字母开头,并且只能包含小写字母,数字和短划线。因此MyApp无法正确。

检查Heroku仪表板中的应用程序页面,找到应用程序的名称,然后相应地更新配置。以下是带有随机命名的Heroku应用程序的插件配置示例:

<plugin>
    <groupId>com.heroku.sdk</groupId>
    <artifactId>heroku-maven-plugin</artifactId>
    <version>0.3.0</version>
    <configuration>
        <appName>hidden-badlands-1234</appName>
    </configuration>
</plugin>