Four things Heroku stumbled upon when deploying a web app created in Java with GitHub

Trigger I had a web application I created on GitHub, "I want to publish it in a moving state!" That was the reason why I started to feel that.

Various googles "It looks like Heroku can be used." I found out that, so I decided to deploy it after studying.

Source: https://github.com/ShandyGaffLover/sample001

Premise ・ Heroku for the first time ・ Experienced Java, Git, Maven ・ GitHub account created

What I did Create Heroku account ⇒ GitHub integration I was able to do it relatively smoothly while googled.

The articles I referred to are as follows: I tried Heroku, which can publish web applications for free --Qiita https://qiita.com/fkooo/items/0365b50d4534a236dcb2

Heroku Usage Memo (Java)-Qiita https://qiita.com/opengl-8080/items/9dc9243c4e68cd0674f8

Stumble

① "I don't know the language of the app" and it doesn't build

Phenomenon After selecting the repository to be linked and the branch to deploy, when the "Deploy Branch" button was pressed, "No default language could be detected for this app." Was displayed.

builderror.png

Cause Because Buildpack is not set.

Correspondence Click "Add build pack" from the bottom of the "Settings" tab page, and select "heroku / java" to add it.

Result When I pressed the "Deploy Branch" button again, I still got a build error as shown below.

wherepomis.png

② "pom.xml cannot be found" and it is not built

Phenomenon After responding to ①, when the "Deploy Branch" button was pressed again, "Could not find a pom.xml file! Please check that it exists and is committed to Git." Was displayed.

Cause Because pom.xml does not exist directly under the repository.

I originally created the sample001 project under the training repository, so pom.xml was in the location training / sample001 / pom.xml. Apparently you can't deploy to Heroku at this location.

  • There was a similar example. Heroku: I'm addicted to Buildpack errors-Qiita https://qiita.com/arekore0/items/eae550bdbcc78eeac082

Correspondence I created a new repository sample001, placed pom.xml directly under it, and moved the source.

Result When I pressed the "Deploy Branch" button again, the build was successful as shown below. You did it!

buildsuccess.png

I thought ... for a moment

apperror.png

When I access the URL, I get an Application Error ...

③ Web process is not running after deployment

Phenomenon After successful deployment, click the "View" button to access the application URL, and a screen notifying Application Error will be displayed. If you refer to the log, it will be displayed as follows.
2018-12-06T07:09:36.166348+00:00 heroku[router]: at=error code=H14 desc="No web processes running" 

Cause The web application is not running without the Procfile being created. [^ 1] [^ 1]: I'm not so sure if this Japanese is technically correct. Anyone who is familiar with the relationship between Procfile and deployed assets, would appreciate it if you could point out any mistakes.

Correspondence Refer to the following, (1) Create a Procfile, and (2) Add webapp-runner to the plugin of pom.xml. Deploying Tomcat-based Java Web Applications with Webapp Runner | Heroku Dev Center https://devcenter.heroku.com/articles/java-webapp-runner#deploy-your-application-to-heroku

Result ![apperror.png](https://qiita-image-store.s3.amazonaws.com/0/322008/7147b541-4dc2-9820-d0fb-7ef3eddaf975.png)

The Application Error is still displayed. Yeah ... why ...

④ "war file does not exist" is displayed in the log

Phenomenon After responding to (3), if the deployment is successful and the "View" button is pressed to access the application URL, a screen notifying Application Error will be displayed. If you refer to the log, it will be displayed as follows.
2018-12-06T10:51:25.163976+00:00 app[web.1]: The specified path "target/*.war" does not exist.

I was confused because I didn't know the cause at first [^ 2], but in most cases, the cause is often poor.

Cause Because packaging of pom.xml was not described.

Correspondence Specify "war" in packaging of pom.xml.

Result Successful deployment!

Summary When using Heroku for the first time, you should be aware of the following. (1) Buildpack settings are required. (2) For Java, it is necessary to place pom.xml directly under the repository. ③Procfile is required.

I was afraid that I forgot to specify "war" in of pom.xml. I'm sorry. [^ 2] [^ 2]: Why did it work with local tomcat?

Recommended Posts

Four things Heroku stumbled upon when deploying a web app created in Java with GitHub
A story that stumbled when deploying a web application created with Spring Boot to EC2
Deploy a Java web app on Heroku
[Java] Deploy a web application created with Eclipse + Maven + Ontology on Heroku
Things you often use when doing web development in Java
I created a PDF in Java.
The first thing to do when you want to be happy with Heroku on GitHub with Eclipse in Java
When seeking multiple in a Java array
Create a TODO app in Java 7 Create Header
Try making a calculator app in Java
Split a string with ". (Dot)" in Java
Try with resources statement in web app
Read a string in a PDF file with Java
Create a CSR with extended information in Java
Deploy Java web app to Azure with maven
How to display a web page in Java
A note when you want Tuple in Java
Let's create a super-simple web framework in Java
Let's create a TODO application in Java 11 Exception handling when accessing TODO with a non-existent ID