Four things Heroku stumbled upon when deploying a web app created in Java with GitHub
Trigger h1>
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 h1>
・ Heroku for the first time
・ Experienced Java, Git, Maven
・ GitHub account created
What I did h1>
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 h1>
① "I don't know the language of the app" and it doesn't build h2>
Phenomenon h3>
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.
Cause h3>
Because Buildpack is not set.
Correspondence h3>
Click "Add build pack" from the bottom of the "Settings" tab page, and select "heroku / java" to add it.
Result h3>
When I pressed the "Deploy Branch" button again, I still got a build error as shown below.
② "pom.xml cannot be found" and it is not built h2>
Phenomenon h3>
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 h3>
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 h3>
I created a new repository sample001, placed pom.xml directly under it, and moved the source.
Result h3>
When I pressed the "Deploy Branch" button again, the build was successful as shown below. You did it!
I thought ... for a moment
When I access the URL, I get an Application Error ...
③ Web process is not running after deployment h2>
Phenomenon h3>
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 h3>
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 h3>
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 h3>
![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 h2>
Phenomenon h3>
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 h3>
Because packaging of pom.xml was not described.
Correspondence h3>
Specify "war" in packaging of pom.xml.
Result h3>
Successful deployment!
Summary h1>
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?