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

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

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="..."

Java Web App Crashes on Heroku with webapp-runner

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.

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.

Error deploying spring app on heroku

Error on running heroku open after deploying
Error: Error: Unable to access jarfile target/*.jar
I am not sure how to fix this. I added something like this in procfile looking at other SO questions.
web: java -Dserver.port=$PORT -jar target/RootScopeIT_Riot-1.0-SNAPSHOT.war
web: java -jar target/dependency/webapp-runner.jar target/*.war
On running heroku open gives this error.
Please help me to fix this. I have been struggling for days. Thank you

Categories

Resources