Deploy any Java webapp via war to Heroku

Heroku Java support is something I longed for, but they apparently don't support deploying a plain, old war file to Heroku.

I don't like that; I've got my own continuous integration setup, and I want to compile my files on my own box - this allows me to keep my own Maven proxy with my own dependencies - which sometimes are patched versions of public ones -  so that I don't need to push everything on a public repo. I don't want to be forced to build everything on Heroku, and I don't want to compile anything I push - I'd usually push to Heroku stable versions only, or maybe integration versions that pass unit, integration and acceptance tests.

So what? Don't worry, deployment is possible.



Setup an heroku-aware git repository and a Cedar stack app, and add the files you see above; your dir structure should look like:

pom.xml
Procfile
src/
     main/
             java/
                    root/
                           StartWebApp.java
             resources/
                             mywebapp.war


Now a simple

git push heroku master


Should do the trick, and let you see your fully deployed war app.


There're still things you need to be aware of; file persistence may not work as expected, since filesystem is ephemeral, and I still need to figure out things related to database configuration, but those should not come at a great expense.

I'll post updates in the future as soon as I get them right.



Alan Franzoni

Read more posts by this author.

Trieste, Italy
comments powered by Disqus