SpiderGwen
SpiderGwen

Reputation: 73

Heroku Procfile Web Process for Springboot Application

I'm deploying a Springboot Application to Heroku and getting this error message:

2020-06-26T09:26:58.880610+00:00 heroku[web.1]: State changed from starting to >crashed 2020-06-26T12:16:58.291701+00:00 heroku[web.1]: State changed from crashed to >starting 2020-06-26T12:17:05.611518+00:00 heroku[web.1]: Starting process with command >java -war target/InfinityBank-1.0.war 2020-06-26T12:17:08.625648+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults >based on dyno size. Custom settings will override them. 2020-06-26T12:17:08.635316+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: ->Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8 2020-06-26T12:17:08.635417+00:00 app[web.1]: Unrecognized option: -war 2020-06-26T12:17:08.635449+00:00 app[web.1]: Error: Could not create the Java >Virtual Machine. 2020-06-26T12:17:08.635471+00:00 app[web.1]: Error: A fatal exception has >occurred. Program will exit. 2020-06-26T12:17:08.710255+00:00 heroku[web.1]: Process exited with status 1 2020-06-26T12:17:08.767963+00:00 heroku[web.1]: State changed from starting to >crashed

It looks like something is wrong with my Procfile. This is the only line inside the Procfile:

web: java -war target/InfinityBank-1.0.war

This is where I'm confused about. I actually don't know what the web process should be for my application.

An article from the Heroku website says it should be

This might be the web process type for an executable Java JAR file, such as when using Spring Boot:

web: java -jar target/myapp-1.0.0.jar 

Article link: https://devcenter.heroku.com/articles/procfile#more-process-type-examples

I'm not sure what this means in my case. I don't see such a jar file anywhere in my source code. If it matters, my application is war packaging.

Upvotes: 1

Views: 1553

Answers (1)

SpiderGwen
SpiderGwen

Reputation: 73

I finally figured this out in case anyone faces the same problem. You can find the jar file in your pom.xml file. For example, if you find this section in your pom.xml file


<groupId>space.earth</groupId>
    <artifactId>InfinityBank</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>InfinityBank</name>
    <description>Demo project for Spring Boot</description>

The jar file in the Procfile should be

web: java -jar target/InfinityBank-0.0.1-SNAPSHOT.jar

Another tip for deploying jar packaging Springboot application to Heroku is to include

server.port=${PORT:8080}

in the application.properties file.

Upvotes: 3

Related Questions