Java Spring MVC无法在Heroku上启动应用程序.错误H10(找不到webapp运行程序) [英] Java Spring MVC can't start app on Heroku. Error H10 (can't find webapp runner)

查看:77
本文介绍了Java Spring MVC无法在Heroku上启动应用程序.错误H10(找不到webapp运行程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to run my app on Heroku but it doesn't work. From logs I can see the below:

2016-01-18T13:38:31.621218 + 00:00 heroku [web.1]:进程退出 状态1 2016-01-18T13:38:48.101117 + 00:00应用程序[web.1]:错误:无法执行 访问jarfile target/dependency/webapp-runner-8.0.30.1.jar

2016-01-18T13:38:31.621218+00:00 heroku[web.1]: Process exited with status 1 2016-01-18T13:38:48.101117+00:00 app[web.1]: Error: Unable to access jarfile target/dependency/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.100249+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.

2016-01-18T13:38:48.700243 + 00:00 heroku [web.1]:状态从 开始崩溃2016-01-18T13:43:12.241285 + 00:00 heroku [router]: at =错误代码= H10 desc =应用程序崩溃"方法=获取路径="/" host = macfol.herokuapp.com request_id = c6418015-843d-4f5a-8dde-83130e94a7c6 fwd ="159.220.74.5" dyno = connect = service = status = 503字节=

2016-01-18T13:38:48.700243+00:00 heroku[web.1]: State changed from starting to crashed 2016-01-18T13:43:12.241285+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=macfol.herokuapp.com request_id=c6418015-843d-4f5a-8dde-83130e94a7c6 fwd="159.220.74.5" dyno= connect= service= status=503 bytes=

为了使Heroku最终找到该.jar,我一直试图修改pom.xml和procfile都没有成功.

I have been unsuccessfully trying to modify both pom.xml as well as procfile in order that Heroku will finally find that .jar.

有procfile:

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>

可以在maven依赖项中找到缺少"的jar.

The "missing" jar can be found in maven dependencies.

感谢您的帮助

编辑 procfile现在是:

EDIT The procfile is now:

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

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

没有结果...

编辑2

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

There is some progress as it crashes elsewhere ;)

编辑3 工作正常!谢谢大家使这一切成为可能.终于我的应用程序在那里了.我花了12个月才达到这一点. 再次感谢你! :)

EDIT 3 It's working! Thank you all for making this possible. Finally my app is there. It took me 12 months to reach this point. Thank you again! :)

推荐答案

  1. 首先删除pom.xml中的开始<pluginManagement>和结束<pluginManagement/>标记(请勿删除其中的内容).通过包含此内容,将不会创建dependency目录和webapp-runner-8.0.30.1.jar,并且在执行java命令时应用程序将崩溃.

  1. First Remove the start <pluginManagement> and end <pluginManagement/> tags in pom.xml (Do not delete the content inside it). By including this, the dependency directory and the webapp-runner-8.0.30.1.jar will not be created and the application is getting crashed when executing the java command.

finalName标记更改为<finalName>kamienica</finalName>.现在,您在<finalName>...</finalName>标记中具有大写字母(K).在web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/kamienica.war

Change the finalName tag to <finalName>kamienica</finalName> . Right now you have the capital letter(K) in the <finalName>...</finalName> tag. Change it to small letter as you named it in web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/kamienica.war

maven-war-plugin插件中将名称更改为<warName>kamienica</warName>

Change the name to <warName>kamienica</warName> in maven-war-plugin 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>

这篇关于Java Spring MVC无法在Heroku上启动应用程序.错误H10(找不到webapp运行程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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