Heroku无法访问jetty-runner jar文件 [英] Heroku unable to access jetty-runner jar file

查看:146
本文介绍了Heroku无法访问jetty-runner jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jetty-runner.jar部署一个Spring MVC应用程序到Heroku,但是在部署中出现错误。
Heroku日志只显示:

 错误:无法访问jarfile target / dependency / jetty-runner.jar 
状态从开始崩溃到
过程退出状态1

然而,应用程序工作正常,如果我使用以下任一方式在本地运行它:

  heroku local web -f Procfile.windows 

code>

  java  - jar target \dependency\jetty-runner.jar target\ * .war 

在运行mvn package命令时,在我的计算机上正确创建了target / dependency / jetty-runner.jar。

我的Procfile如下所示:

  web:java $ JAVA_OPTS -jar target / dependency / jetty-runner.jar --port $ PORT target / *。war 

我的pom.xml文件和项目代码位于:
https://github.com/gfigueroa/nlp-tools-spring-heroku



其他详情



在部署后我运行了命令 heroku run ls target ,它只显示 .war 文件。

解决依赖项文件夹在部署时并未创建,即使是在本地打包项目时也是如此。方案

您的 maven-clean-plugin 正在删除中的 jar 当您尝试在 Heroku 上构建您的应用程序时,请执行以下操作:c> dependency directory和其他所需的目录。

您可以在 pom.xml 中删除​​ maven-clean-plugin ,或者修改它。



最佳选择是删除pom.xml中的插件

 < plugin> 
< artifactId> maven-clean-plugin< / artifactId>
< version> 2.5< / version>
<执行次数>
<执行>
< id> clean-jar-artifacts< / id>
<阶段>安装< /阶段>
<目标><目标>清洁< /目标>< /目标>
<配置>
< excludeDefaultDirectories> true< / excludeDefaultDirectories>
<档案集>
< fileset>
<目录>目标< /目录>
<排除>
< exclude> *。war< / exclude>
< /不包括>
< / fileset>
< / filesets>
< / configuration>
< /执行>
< /执行次数>
< / plugin>

或者您可以排除依赖项/ *。jar < exclude> ..< / exclude> 标签来删除。但是这个选项可能会删除成功部署应用程序所需的其他必需文件夹。所以我不会推荐这个。

 < plugin> 
< artifactId> maven-clean-plugin< / artifactId>
< version> 2.5< / version>
<执行次数>
<执行>
< id> clean-jar-artifacts< / id>
<阶段>安装< /阶段>
<目标>
< goal> clean< / goal>
< /目标>
<配置>
< excludeDefaultDirectories> true< / excludeDefaultDirectories>
<档案集>
< fileset>
<目录>目标< /目录>
<排除>
< exclude> *。war< / exclude>
< exclude>依赖项/ *。jar< / exclude>
< /不包括>
< / fileset>
< / filesets>
< / configuration>
< /执行>
< /执行次数>
< / plugin>

看看 page 获取更多信息。


I'm deploying a Spring MVC app to Heroku using jetty-runner.jar, but I get an error in the deployment. The Heroku logs only show:

Error: unable to access jarfile target/dependency/jetty-runner.jar
State changed from starting to crashed
Process exited with status 1

However, the app is working correctly if I run it locally using either:

heroku local web -f Procfile.windows

or

java -jar target\dependency\jetty-runner.jar target\*.war

The file under "target/dependency/jetty-runner.jar" is created correctly in my computer when running the "mvn package" command.

My Procfile looks like this:

web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.war

My pom.xml file and project code are located in: https://github.com/gfigueroa/nlp-tools-spring-heroku

ADDITIONAL DETAILS

I ran the command heroku run ls target after deploying and it only shows the .war file. The dependency folder was not created when deploying, even though it was when I packaged my project locally.

解决方案

Your maven-clean-plugin is deleting the jar file in dependency directory and other required directories when you try to build your app on Heroku.

You can either remove the maven-clean-plugin in the pom.xml or you can modify it.

Best option is to remove the plugin below in pom.xml

              <plugin>
                  <artifactId>maven-clean-plugin</artifactId>
                  <version>2.5</version>
                  <executions>
                    <execution>
                      <id>clean-jar-artifacts</id>
                      <phase>install</phase>
                      <goals><goal>clean</goal></goals>
                      <configuration>
                        <excludeDefaultDirectories>true</excludeDefaultDirectories>
                        <filesets>
                          <fileset>
                              <directory>target</directory>
                              <excludes>
                                <exclude>*.war</exclude>
                              </excludes>
                          </fileset>
                        </filesets>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>

Or you can exclude the dependency/*.jar from deleting by simply adding the <exclude>..</exclude> tags as specified below. But this option might delete other required folders which are necessary for deploying the app successfully. So I would not recommend this.

    <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                    <executions>
                        <execution>
                            <id>clean-jar-artifacts</id>
                            <phase>install</phase>
                            <goals>
                                <goal>clean</goal>
                            </goals>
                            <configuration>
                                <excludeDefaultDirectories>true</excludeDefaultDirectories>
                                <filesets>
                                    <fileset>
                                        <directory>target</directory>
                                        <excludes>
                                            <exclude>*.war</exclude>
                                            <exclude>dependency/*.jar</exclude>
                                        </excludes>
                                    </fileset>
                                </filesets>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

Look at this page for more information.

这篇关于Heroku无法访问jetty-runner jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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