Introduction
Since it cost me a lot of time messing around with maven, the embedded Jetty server and the Maven appassembler plugin i’ve created a quickstart example project for personal usage of migrating my Apache CXF java projects to the Heroku Java cloud. I use Apache CXF quite often when it comes to building proxies (middleware) between 2 different platforms or API which both have their own limitations, look at salesforce.com and SAP or the Google API for example. Perhaps this might come in handy for any other person/company who wants to start migrating his Java projects to the Cloud with Heroku. Fork it here:
https://github.com/erikkramer/heroku-spring-cxf-quickstart
Explanation
- - Fork the git repository
- - To use the project in Eclipse use: ‘mvn eclipse:eclipse’, and then import it.
- - Build the project: ‘mvn install’, result should be something like this:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Fri Nov 18 15:48:32 CET 2011
[INFO] Final Memory: 28M/214M
[INFO] ------------------------------------------------------------------------
- - add the REPO env var to your shell: ‘export REPO=~/.m2/repository’
- - now try to start the project locally: ‘sh target/bin/webapp’, result should be something like this below, you webapp should now be running from the embedded Jetty server on port 8080. Check: http://localhost:8080/
Nov 18, 2011 3:54:58 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be /geocoderService
INFO - ContextLoader - Root WebApplicationContext: initialization completed in 1356 ms
INFO - log - started o.e.j.w.WebAppContext{/,file:/home/ekramer/workspaceWebCRMWaypoint/heroku-spring-cxf-quickstart/src/main/webapp/}
Nov 18, 2011 3:54:58 PM org.apache.cxf.transport.servlet.CXFServlet updateContext
INFO: Load the bus with application context
INFO - BusApplicationContext - Refreshing org.apache.cxf.bus.spring.BusApplicationContext@19299f5: startup date [Fri Nov 18 15:54:58 CET 2011]; parent: Root WebApplicationContext
INFO - DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1d8417c: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@691dee
Nov 18, 2011 3:54:58 PM org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
INFO: Servlet transport factory already registered
INFO - log - Started SelectChannelConnector@0.0.0.0:8080
- - Create an app on the Heroku cedar stack: ‘heroku create -s cedar’
- Push the project to the created app and start it on the Heroku Cedar stack: ‘git push heroku master’
- - Your example app should be running now if you see something like this:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.877s
[INFO] Finished at: Fri Nov 18 15:11:28 UTC 2011
[INFO] Final Memory: 15M/490M
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> web
-----> Compiled slug size is 8.7MB
-----> Launching... done, v13
http://freezing-mountain-8097.herokuapp.com deployed to Heroku
To git@heroku.com:freezing-mountain-8097.git
8a155ca..bada9b1 master -> master
For more information on how to use GIT on Heroku visit the developer pages on the http://www.heroku.com, they have pretty decent turorials on how to use it! Good luck! If you have questions just tweet me on @erikkramer