Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying spring boot application to heroku - error message "No web processes running"

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?

like image 414
steady_progress Avatar asked Feb 05 '20 22:02

steady_progress


People also ask

Can I deploy spring boot application to Heroku?

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.

What is 503 error Heroku?

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.


3 Answers

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 enter image description here

Pom (with WebRunner plugin) enter image description here Demo Application (Note the use of SpringBootServletInitializer). You will get 404 if you don't use it.

enter image description here

Home page enter image description here

Heroku logs enter image description here

like image 81
s7vr Avatar answered Oct 17 '22 06:10

s7vr


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

like image 42
reflexdemon Avatar answered Oct 17 '22 05:10

reflexdemon


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:

  1. Spring Boot can bundle your application with an embedded web server. This would avoid the issue altogether.
  2. Use webapp-runner which will run a WAR file for you. Heroku's Maven plugin can help you setting it up.

I recommend the first approach. Heroku has a great walkthrough on setting up a Spring boot application.

like image 34
Malax Avatar answered Oct 17 '22 06:10

Malax