I created a spring boot web application (in IntelliJ IDEA), which runs locally without problems.
I then built an artifact (Build -> Build Artifacts... -> my_app:jar -> Build), which created a jar file in directory "out".
I tried to deploy the app to heroku following exactly the steps described in this walkthrough by heroku: https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku
Note: the walkthrough does not mention a Procfile so I didn't create one.
When opening the app's address in the browser I faced an "Application error".
The logs show that building the app was successful but there are apparently "No web processes running":
2020-02-06T20:42:19.262364+00:00 app[api]: Release v1 created by user [email protected] 2020-02-06T20:42:19.598724+00:00 app[api]: Release v2 created by user [email protected] 2020-02-06T20:42:19.262364+00:00 app[api]: Initial release by user [email protected] 2020-02-06T20:42:19.598724+00:00 app[api]: Enable Logplex by user [email protected] 2020-02-06T20:46:11.000000+00:00 app[api]: Build started by user [email protected] 2020-02-06T20:46:56.626428+00:00 app[api]: Release v3 created by user [email protected] 2020-02-06T20:46:56.626428+00:00 app[api]: Deploy 93b6dfea by user [email protected] 2020-02-06T20:47:04.000000+00:00 app[api]: Build succeeded 2020-02-06T20:48:22.485742+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=my-app.herokuapp.com request_id=22e30a92-5094-4f8b-a51c-3f21177b19dc fwd="95.88.203.176" dyno= connect= service= status=503 bytes= protocol=https
I checked whether a dyno was running using the following command:
heroku ps
Result:
No dynos on ⬢ infinite-sky-81114
I then ran the following command to start a dyno:
heroku ps:scale web=1
Result:
Scaling dynos... ! ▸ Couldn't find that process type (web).
So the application doesn't run because there is no dyno - but I am not able to start a dyno.
How can I make this work?
The Spring Boot model of deploying standalone applications is a great fit for Heroku. You can use either Maven or Gradle to deploy a Spring application on Heroku, but for this guide we'll assume that you're using Maven and have Maven 3 installed on your machine.
Heroku's HTTP router serves unstyled HTML with HTTP status code 503 (Service Unavailable) when your app encounters a system-level error, or while maintenance mode is enabled.
Assuming you are using JAR, Procfile
will be created by default. Are you sure your web dyno is still running ? If you are using cli, you could check using heroku ps
to see what is the status. If it says no dynos you can scale up using heroku ps:scale web=1
and try heroku open
to launch app.
If your using WAR you can follow https://devcenter.heroku.com/articles/war-deployment and yes you need the Procfile.
Also while running the spring boot application on standalone tomcat don't forget to follow steps here https://docs.spring.io/spring-boot/docs/2.1.10.RELEASE/reference/html/howto-traditional-deployment.html
Here are some screen shots that I took while doing spring boot heroku integration.
ProcFile
Pom (with WebRunner plugin) Demo Application (Note the use of SpringBootServletInitializer). You will get 404 if you don't use it.
Home page
Heroku logs
Create Procfile
with just
web: java -Dspring.profiles.active=default -Dserver.port=$PORT -jar target/*.jar
Also don't forget to add the source to heroku to heroku git by doing heroku create
. This will put the source code to heroku git and when the dynos are built it will deploy your application from the source code.
Here is my example project that is starter for you to deploy spring boot application to cloud. https://github.com/reflexdemon/cloud-project
I have also written a blog on deploying spring boot application to heroku. Hope that helps. https://blog.vpv.io/2018/02/undocumented-java-web-application.html
It looks like you're trying to deploy a WAR file. You cannot run a WAR file without a web server. You have two options:
I recommend the first approach. Heroku has a great walkthrough on setting up a Spring boot application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With