简体   繁体   中英

Heroku unable to access jetty-runner jar file

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.

I had the similar problem , until I add into pom.xml file with latest jetty-runner (org.eclipse.jetty)

<plugins>
   <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>org.eclipse.jetty</groupId>
                              <artifactId>jetty-runner</artifactId>
                              <version>9.4.4.v20170414</version>
                       <destFileName>jetty-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM