Java Spring Application on Azure Cloud
Microsoft states to developers using Azure that one can build applications using any language, tool or framework. This blog post will show you how to deploy a Spring application on an Azure cloud. Our first step will be to install a Jetty instance on to the cloud, and then we’ll import jars and do any necessary fine tuning to get our sample spring application on the cloud.
There’s a great blog post to get you started with getting a Jetty instance on the cloud that I want to refer you to: http://blogs.msdn.com/b/dachou/archive/2010/03/21/run-java-with-jetty-in-windows-azure.aspx
Next download a sample spring application. I was able to get one at: https://src.springframework.org/svn/spring-samples/petclinic/trunk/ [Dead Link]
The presence of a pom.xml file in the root directory tells us that the project can built using maven. Install maven if you don’t have it, and then run an mvn clean install from the root directory. That command will run all unit tests and build the solution.
If I recall, I had a little bit of difficulty with a couple of the tests. I was able to comment out the failing tests, and the sample application ran fine for our purposes. Once you get the spring application built, copy the *.war file to the web app dir of your jetty instance. Startup your jetty instance locally and confirm that the spring app is working.
If the spring application works locally, the next step is to move it to the cloud
Rename your *.war to test.war so that it matches the war from the blog above. Overwrite the war from above with your new war containing the spring application. The hardest part about getting a spring application to load instead of just the jetty splash page from the original tutorial is getting your JSP jars in place. To acquire the JSP jars that were needed I downloaded Jetty 7.4.5.v20110725, and copied the jetty jsp folder (jetty-distribution-7.4.5.v20110725\lib\jsp) to JettyWorkerRole\app\jetty7\lib\jsp and with that your spring application is ready to be deployed to the cloud.
I had a lot of problems putting this tutorial together and generally wouldn’t recommend a java application on an Azure cloud. There was tremendous difficulty debugging, because you can’t access the console that was started by the worker role. When issues arise, I would just get blank screens in my web browser, and I had to assume (correctly, though I didn’t know it at the time) the issue was related to jsp jars missing.