Java Web App Crashes on Heroku with webapp-runner - java

I have an existing Java web app project. It works locally with Tomcat. I converted it into a maven project and deployed it on Heroku using webapp-runner. The application is deployed successfully but it does not run; it crashes. I cannot figure out from the logs what the reason is.
My Procfile looks like this: web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
App structure
logs

It states clearly in the log: The specified path target/*.war does not exist. Run your build locally using mvn clean package and see if you actually have a war file in the target directory and what it's name is.
Then, open your Procfile and replace target/*.war with target/whateverTheNameIs.war and retry.

Related

How to add new relic java agent to a heroku war

I am facing issue to add java agent to heroku WAR.
Our procfile looks as below,
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
I am following this link to setup newrelic on heroku
https://docs.newrelic.com/docs/agents/java-agent/heroku/java-agent-heroku
but this talks only about jar.

How to edit Procfile in Heroku when using heroku war:deploy myapp.war

I'm trying to edit the Procfile in Heroku, however it seems like you can't edit it when using the command heroku war:deploy myapp.war to deploy the war file. Any suggestion on how i can either edit this, or run another shell script in web phase?
I've tried to include the Procfile directly with --include, however it gets overwritten by the default Procfile which is provded by Heroku.
heroku war:deploy doesn't support a custom Procfile. However, you can customize the command using the following config vars:
JAVA_OPTS
WEBAPP_RUNNER_OPTS
You can set this with a command like heroku config:set WEBAPP_RUNNER_OPTS="..."

Heroku, Java Web app - free dynos Procfile - How to create proper Procfile

I'm trying to upload my 1st Java Web app to the web but I can't handle the Procfile. After deploy, there is info about successfully deploy but when I try to run the app there are an error and server logs seems to indicate that Procfile is empty / does not exist.
In server resources there is following dyno:
java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
and in thetutorial there is
"Your Procfile will look something like this:"
web: java $JAVA_OPTS -cp target/classes:target/dependency/* HelloWorld
but I don't udnerstand what is happening here. I know only that there should be web: at the beggining for web-app I don't understand the rest of it. Can some one help me undrstand it so I could create proper Procfile for my app?
If you have heroku installed and if you have only .jsp and .class you can do as it follows, and you don't need a procfile:
$ heroku create <app_name>
Create a WAR file of your app in Eclipse for example:
Right click on the project > Export > WAR file
then you have to deploy it to heroku:
$ heroku war:deploy <path_to_war_file> --app <app_name>
then you'll see the app going to heroku, some logs and blah blah blah. After that you can open your application:
$ heroku open --app <app_name>
Simple. But if you need some help about procfile, take a look here

Debug embedded tomcat on heroku

I'm working on a Java web application. I already deploy it to heroku. Now I'm trying to remote debug my application using IntelliJ with no results. To deploy it I use git, then heroku starts it reading and executing the Procfile. And here is the problem. Everywhere I see that to debug I must use this line in my Procfile: web: java -agentlib:jdwp=transport=dt_socket,server=y,address=9090,suspend=n -jar target/myapp.jar. But I can't put this line on my Procfile because I execute my app using web: sh target/bin/webapp and not java. There's some workaround to simply debug my application.
You'll need Heroku Exec and the Heroku Java CLI.
First, put your agentlib args into the JAVA_TOOL_OPTIONS env var:
$ heroku config:set JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,address=9090,suspend=n"
This way, the java process in your target/bin/webapp script will pick it up automatically.
Then run:
$ heroku ps:forward 9090
And you can connect to localhost:9090 from your IDE.

Steps needed to deploy war on Heroku

I have spring source tool with Maven. And I have one Java project which I want to deploy on Heroku.
Can anybody tell me steps to deploy on Heroku?
Many Thanks
Create war file in Maven. You can do this by referring here
Install the Heroku Toolbelt from here
Open the command prompt (for Windows) and type:
heroku login
It will prompt to enter user name and password. Enter the credentials of your heroku account.
Now, to install the heroku-deploy plugin, enter the code:
heroku plugins:install heroku-cli-deploy
Now deploy the war file to the heroku server by this code:
heroku deploy:war --war <path_to_war_file> --app <app_name>
If you are in an application directory, the --app parameter can be omitted:
heroku deploy:war --war <path_to_war_file>
Your App will be successfully deployed to the heroku server.
It's all well explained here :
https://devcenter.heroku.com/articles/java
How to deploy war file to Heroku
Register Heroku account
Install heroku-cli
Install JDK if needed
Install heroku-cli-deploy plugin using command:
heroku plugins:install heroku-cli-deploy
Login to heroku in command line:
heroku login
Create app using command:
heroku apps:create <app_name>
Deploy war file using this command:
heroku war:deploy <path_to_war_file> --app <app_name>
Open app using command:
heroku open -a <app_name>
Reference: Heroku Deploy War/Jar
This url shows exactly how to deploy a war file on heroku:
https://github.com/heroku/heroku-deploy

Categories

Resources