So I made a java web application with a normal pom.xml specifying my maven dependencies. Then, I went through the Heroku step by step tutorial on deploying their already-made web app, which did not help in the least bit. Then, I tried deploying the war, with no luck. Then I tried using the Maven plugin. I'm not sure if Heroku or some blog has a step by step guide on deploying to Heroku, but I need one. Can anyone go over what modifications need to be done to the pom.xml and what the procfile should be? And is it also necessary to have a main method in a java class? I thought each servlet was an entry point. My web app works fine on localhost and when I deploy the war on tomcat. It just doesn't work on Heroku no matter what I do to the pom.xml. I included my pom.xml. enter link description here
Run these commands:
$ heroku plugins:install heroku-cli-deploy
$ heroku deploy:war yourapp.war
Then read WAR Deployment on Heroku's Dev Center.
Related
I'm trying to deploy my fullstack webApp to tomcatServer. Backend part is springBoot app and frontend part is react app. I built that using mvn clean package. I configured my pom file, so maven always runs npm i, npm run build and then it copies all files to webapps backend directory and create war file.
When I have installed the tomcat on the windows, everything works correctly. I have deployed the webApp.war to the tomcat and I can access to my webapp using localhost:8080/webApp.
I tried the same on the mashine with macOS, but localhost:8080/webApp does not work. There is shown whitescreen and all needed files return 404 code to the console.
Do you have some ideas, what is needed to be configured?
Thanks!
Have you tried manually stopping the server(tomcat), again setting it to automatic and re-running the application?
I have a big issue. I'm trying to deploy Spring Boot + Angular 2 web app on heroku but don't know how to do it. I tried several things including:
Making a .war file and deploying it to heroku (source here)
Deploying project as standard java application (source here)
but none of these worked. The first attempt didn't work because I constatly got 404 not found, and the second one didn't work due to, I think, some jar file wasn't found in the location which was described in the Procfile.
Can anyone give me a link, an example, or write a step by step instruction how to achieve this. Thank you.
The most simple way to do it:
run ng build in angular 2 project root (if you are using angular-cli) and copy the content of dist folder to src/main/resources/static/.
create Procfile (for maven):
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar
commit and push changes.
Also, you need spring-boot-starter-web present in dependencies. Which has embedded tomcat and automatically configured to serve static content from the static folder.
If you deploy your app as a standard Java application, you can combine it with the Node.js buildpack to run ng build during the Heroku build.
$ heroku buildpacks:add heroku/nodejs
$ heroku buildpacks:add heroku/java
$ git push heroku master
The Node.js buildpack will detect your package.json, install Node.js and run npm. Then the Java build can proceed as normal.
There is a guide for doing something very similar but with Grunt: Using Grunt with Java and Maven to Automate JavaScript Tasks
Use JHipster: https://jhipster.github.io
Once installed, run:
$ yo jhipster
Then run
$ yo jhipster:heroku
I have a spring app that i am running on local tomcat using maven/intellij. I wanted to deploy it on heorko. When i just pushed the app (without any main class or procfile) i got the error that there is no application running.
I then followed this tutorial https://devcenter.heroku.com/articles/create-a-java-web-application-using-embedded-tomcat
and added changes to pom.xml, created a Main.java class as suggested and created a procfile on root (where the pom.xml file is) and then i pushed it to heroku. I got the same error that application isn't running.
How can i run a spring tomcat app on heroku.
p.s:
Spring configurations are done using <project_name>Configuration.java class and <project_name>Initializer.java.
Try following the guide for Deploying Spring Boot Applications to Heroku. If you're deploying a WAR file, try following the guide for Deploying WAR Files. Otherwise, you'll need to provide more info about your app.
I have a repository on GitHub. It consists of 3 projects. Main web application and libraries. Main application is jar with embedded Tomcat. I would like to deploy main application on Heroku. Can I deploy just prepared jar? If so how?
While it is not recommended to check in binary files (e.g. JARs) into a Git repo, you can try using the third-party Null Buildpack to have Heroku just deploy your repo as-is without compilation. You'll still need to have a Procfile to tell Heroku how to launch your application.
Besides the problems with checking in JARs, this method will also not be running your application on the latest patch JDK. If you want the best of both worlds, you'd need to make your own custom buildpack that downloads the JDK, similar to what the Java Buildpack does.
Heroku allows the option of directly deploying one's Java .war file using heroku deploy:war (the Procfile is automatically managed by heroku in this case).
How does one use NewRelic with such a setup? The current documentation on Heroku DevCenter on NewRelic asks one to place the NewRelic jar in the root folder of the Java application.
How does one achieve this when using heroku deploy:war to directly deploy the app and not via git?
Following up on this question from New Relic support and adding clarifying statements to this old question. Unfortunately as far as I'm aware, it isn't possible to use the New Relic .jar file in an embedded war file without exploding the war.
On Heroku, using deploy:war simply wraps your war in jetty runner. An alternative would be to deploy an app that uses jetty runner by deploying source code instead of a binary. Instructions are here:
If you use the approach above, you should be able to add New Relic to your project.
I received this response from Heroku Support team:
WAR deploy doesn't specifically handle this case. However, it should
work. You can include the New Relic JAR in your WAR and add the
javaagent flag in your JAVA_OPTS config.