Java Spring MVC无法在Heroku上启动应用程序。错误H10(无法找到webapp runner)

时间:2016-01-19 08:53:20

标签: java spring maven heroku

我正在尝试在Heroku上运行我的应用程序,但它不起作用。从日志我可以看到以下内容:

  

2016-01-18T13:38:31.621218 + 00:00 heroku [web.1]:流程已退出   状态1 2016-01-18T13:38:48.101117 + 00:00 app [web.1]:错误:无法执行   访问jarfile目标/依赖/ webapp-runner-8.0.30.1.jar

     

2016-01-18T13:38:48.100249 + 00:00 app [web.1]:设置JAVA_TOOL_OPTIONS   默认值基于dyno大小。自定义设置将覆盖它们。

     

2016-01-18T13:38:48.700243 + 00:00 heroku [web.1]:状态由   开始崩溃2016-01-18T13:43:12.241285 + 00:00 heroku [路由器]:   at =错误代码= H10 desc =" App崩溃" method = GET path =" /"   主机= macfol.herokuapp.com   request_id = c6418015-843d-4f5a-8dde-83130e94a7c6 fwd =" 159.220.74.5"   dyno = connect = service = status = 503 bytes =

我尝试修改pom.xml和procfile都没有成功,以便Heroku最终找到.jar。

有proc文件:

web:    java $JAVA_OPTS -jar target/dependency/webapp-runner-8.0.30.1.jar --target/kamienica

和pom.xml

<?xml version="1.0"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>
    <groupId>kamienica</groupId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>Kamienica</name>

    <properties>
        <springframework.version>4.0.6.RELEASE</springframework.version>
        <hibernate.version>4.3.6.Final</hibernate.version>
        <mysql.version>5.1.31</mysql.version>
        <joda-time.version>2.3</joda-time.version>
        <testng.version>6.9.4</testng.version>
        <mockito.version>1.10.19</mockito.version>
        <h2.version>1.4.187</h2.version>
        <dbunit.version>2.2</dbunit.version>
    </properties>

    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <!-- jsr303 validation -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.1.3.Final</version>
        </dependency>

        <!-- MySQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- Joda-Time -->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${joda-time.version}</version>
        </dependency>

        <!-- To map JodaTime with database type -->
        <dependency>
            <groupId>org.jadira.usertype</groupId>
            <artifactId>usertype.core</artifactId>
            <version>3.0.0.CR1</version>
        </dependency>

        <!-- Servlet+JSP+JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>

        <!-- Testing dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${springframework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>${h2.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>${dbunit.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- for rest -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.4.1.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.4.1</version>
        </dependency>
        <!-- Spring Security -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>


        <dependency>
            <groupId>com.github.jsimone</groupId>
            <artifactId>webapp-runner</artifactId>
            <version>8.0.30.1</version>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>spring-snapshot</id>
            <name>Spring Snapshot Repository</name>
            <url>http://repo.springsource.org/snapshot</url>
        </repository>
    </repositories>
    <build>
        <pluginManagement>
            <plugins>


                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>Kamienica</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>


                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>com.github.jsimone</groupId>
                                        <artifactId>webapp-runner</artifactId>
                                        <version>8.0.24.0</version>
                                        <destFileName>webapp-runner.jar</destFileName>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

            </plugins>
        </pluginManagement>
        <finalName>Kamienica</finalName>
    </build>
    <artifactId>Kamienica</artifactId>
</project>

&#34;失踪&#34; jar可以在maven依赖项中找到。

感谢您的帮助

修改 proc文件现在是:

  

web:java $ JAVA_OPTS -jar target / dependency / webapp-runner.jar --port   $ PORT target / kamienica.war

没有结果......

编辑2

在其他地方崩溃有一些进展;)

enter image description here

编辑3 它正在工作!谢谢大家让这成为可能。最后我的应用程序在那里。我花了12个月才达到这一点。 再次感谢你! :)

2 个答案:

答案 0 :(得分:3)

您的destFileNamewebapp-runner.jar,但是您引用了Procfile中的另一个jar:

web:    java $JAVA_OPTS -jar target/dependency/webapp-runner-8.0.30.1.jar --target/kamienica
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                 Version is redundant

请改用:

web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/Kamienica.war

答案 1 :(得分:3)

  1. 首先删除with r (id, amount, lvl) as (select min(id), min(amount), 1 from t union all select t.id, t.amount, r.lvl + 1 from t, r where t.id > r.id and t.amount > r.amount) select lvl, min(id), min(amount) from r group by lvl order by lvl 中的开始<pluginManagement>和结束<pluginManagement/>标记(不要删除其中的内容)。通过包含它,将不会创建pom.xml目录和dependency,并且在执行java命令时应用程序将崩溃。

  2. webapp-runner-8.0.30.1.jar代码更改为finalName。现在,您在<finalName>kamienica</finalName>标记中有大写字母(K)。在<finalName>...</finalName>

  3. 中将其命名为小写字母时将其更改为小写字母
  4. 将名称更改为web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/kamienica.war插件中的<warName>kamienica</warName>

    maven-war-plugin