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/

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.

This entry was posted in Architecture and Development, Cloud, How To Guide. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

6 Comments

  1. Posted April 3, 2012 at 7:35 am | Permalink

    Great find, I’m going to have to check this one out. Thanks for sharing.
    Very informative….

  2. Posted May 6, 2012 at 10:10 am | Permalink

    Have you thought about adding some videos to your article? I think it might enhance everyones understanding.

  3. Posted May 6, 2012 at 10:10 am | Permalink

    Odd , this page turns up with a dark color to it, what color is the primary color on your webpage?

  4. Posted May 6, 2012 at 10:11 am | Permalink

    It appears to me that this web site doesnt load in a Motorola Droid. Are other people getting the exact same problem? I enjoy this website and dont want to have to miss it whenever Im gone from my computer.

  5. Richard Krajunus
    Posted May 7, 2012 at 9:59 pm | Permalink

    The banner is primarily a dark color, while the rest of the page has a white background. I hope that helps! Thanks for reading, Rich

  6. Richard Krajunus
    Posted May 7, 2012 at 10:05 pm | Permalink

    I never thought about adding videos. Truthfully, this is my first attempt at blogging about anything, and I didn’t know how widely it would be followed. In the meantime, I’d be interested to hear about what parts you found confusing; maybe I could provide clarification?

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*