kolorobot / spring-mvc-quickstart-archetype

The project is a Maven archetype for Spring MVC web application.
http://blog.codeleak.pl
1.05k stars 478 forks source link

Would it run on Heroku ? #68

Closed monarksingh closed 10 years ago

monarksingh commented 10 years ago

Has anybody given it a try on Heroku or AWS for that matter. I was about to start, thought of creating a thread first to capture some reaction, if somebody has already did it.

kolorobot commented 10 years ago

Me not. Please note that session is used, so the app created with the archetype is not scalable "out of the box" (security uses session, flash messages use session too).

monarksingh commented 10 years ago

Yes, I am using memcachier addon and following these https://devcenter.heroku.com/articles/java-webapp-runner steps. Didn' had a luck till now.

monarksingh commented 10 years ago

Managed to get the app up and running http://balloonation.herokuapp.com/, added memcachier for session but still in memory database not working.looking at the logs

monarksingh commented 10 years ago

Turns out HSQL database is not supported and it has nothing to do with memcachier, so TIL in-memory database are not stored in HTTP session ;), Can anybody confirm if this statement is correct !! . let how postgres work with our archetype on heroku

monarksingh commented 10 years ago

Before moving on to postgres saw the logs to find out "java.io.NotSerializableException: com.balloonation.support.web.Message". Changed Message.java to implement Serializable and everything is working as expected with in-memory HSQL database. and now I am confused why it worked.

monarksingh commented 10 years ago

So finally done, Although I have made this issue my work log. but I guess, I should comprise steps on how to deploy&run apps created from this archetype on Heroku(I am assuming that you are doing it from scratch, skip steps if you already performed them).

1) Create sample project out of this archetype, Steps here https://github.com/kolorobot/spring-mvc-quickstart-archetype 2) Create your heroku account and install heroku toolbelt, generate SSH key https://devcenter.heroku.com/articles/getting-started-with-java 3) Create your heroku app using "heroku create", it will generate random name for your app and git remote repo for your code, you can rename your project name using "heroku apps:rename newname" 4) On your local, where your new maven project got created, Initialize your project using "git init" 5) Add heroku remote repo to your project "git remote add heroku git@heroku.com:project.git" 6) Follow steps in https://devcenter.heroku.com/articles/java-webapp-runner for configuring your webapp runner and memcachier(for handling HTTP sessions) 7) create system.properties file at root to specify your java version by specifying "java.runtime.version=1.7" in it 8) create Procfile at root with this target in it "web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT --session-store memcache target/*.war" 9) with all this changes do your git workflow git add . git commit -m "Intial commit" git push heroku master 10) create one dyno(VM sort of thing) using "heroku ps:scale web=1" 11)Run you web app using "heroku open" After step 11) your browser would be opened with your app running. In order to see logs type in "heroku logs" or "heroku logs --tail" if you bumped to "java.io.NotSerializableException: com.balloonation.support.web.Message". Change Message.java to implement Serializable.

If you want to integrate postgres or anyother DB, attach required DB addon to your heroku app, change persistance.properties.

kolorobot commented 10 years ago

This is great! I will check this and publish a how to somewhere. Thanks! 4 lis 2014 14:52 "Monark Singh Yede" notifications@github.com napisał(a):

Closed #68 https://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/68.

— Reply to this email directly or view it on GitHub https://github.com/kolorobot/spring-mvc-quickstart-archetype/issues/68#event-188020798 .