Introduction of Amazon Web Services with Spring Framework

November 13, 2008

In these times when there is big recession in the economic world. Every company wants to cut down its costs. For the software development, it is very good thing about java is its very huge and impressive open source technologies and framework. Among those,
Spring is most popular and framework for JEE development. There are huge number of success stories regarding spring. I started using it in 2002. I found it one of the best solutions. Company can select open source technologies for the development. But what happens, when software development complete and ideas becomes reality. Company controlled its development cost. But now a big expense is going to occur in the shape of deployment and server maintenance. Servers cost cannot be reduced. But now it is very much possible to reduce it using Amazon Web Service.

When companies start their projects or products, the deployment structure is designed and suggested. The Deployment structure includes software and hardware costs. This is very much critical for the companies to launch their project with one of the best and optimized servers. Those servers consist of heavy processors, Ram in GBs; Storage must be the big enough to fulfill the requirements. Taking daily backups of the system. 7*24 availability of machines. High bandwidth required. Company needs extra human and software resources to check the systems. So the system that is required for the above requirements have a very big cost. Everyone has very good and unique ideas. And those ideas become reality. But when the time comes to present it to the world, it has a very big cost. Product realization for the outer world needs some time. This time increases the cost of the product/project in tremendous way. Only those companies who survive in this time can be in win full positions.

I am working in a company, that has unique and one of the still growing business of mobile content management. This company also provides a very platform for the sms based services. So we need very heavy machines to fulfill the requirements.

For the product development, our choice was JEE. And in JEE, obvious choice was spring framework. We did build our product using Spring, Hibernate and JPA (the deadly combination). We did a very heavy stress testing on it. And output was very ideal, matching with our requirements.

There is always a debate, that where to put content. Some suggest putting it into the Database and some suggest for File System. For every mobile content, we need some previews to display the content on web or wap. And some content owner wants to lock their content being forward to the other mobile. We also did some Transco ding techniques to deliver the content specifically to the device specification. So after a very big debate, we choose database with the decision that ultimately we will shift our content to the File Systems. We stored our content in Blobs. We write some oracle service to automate the backups of the content.

After completion and successful launch, we started some work on more content services to the other companies. Also we sit together to decide that, how we can shift our content to the file systems?

In the mean time Amazon came with its Amazon Elastic Compute Cloud (Amazon EC2) and other services. And we did some study on it. We finally came with the idea to shift out complete servers shift to the Amazon. Amazon provides a very impressive Storage in the shape of Amazon Simple Storage Service (Amazon S3). Amazon also provides a queue-based, message-oriented middleware (MOM) for processing unlimited messages that have unlimited senders and receivers. The best thing about its web service API to manipulate it. Amazon S3 used to store the data. It also provides search, add, delete and update operations on it. Amazon also provides access control to the contents. You can also make the content available for general public.

In Amazon S3 and SQS provided us the complete solution for the content storage. When end user uploads content we store that content in S3 and also create a message with content id for tans coding and thumbnail (for images) to content processing Queue. So message receiver lookups the content processing Queue for tans coding, and process the Transco ding on it and then deletes that message from queue.

In these times when there is big recession in the economic world. Every company wants to cut down its costs. But the servers cost cannot be reduced. But now it is very much possible to reduce it using Amazon Web Service.

I started on some Step by Step application for Spring framework and Amazon.
This is a web based interface to manage the content on Servers. I have also used database (MySQL) to store some content information in it.

The S3 on Spring web application demonstrates the basic Amazon S3 operations:
1. Logging into Amazon S3
2. Listing all buckets
3. Listing all content in a bucket
4. Bucket actions (upload content in a bucket)
5. Content actions (delete and upload)
6. Downloading an content from a bucket

1. Java SE version 5 or above
2. Spring Framework
3. Hibernate3
4. JPA
5. JetS3t (It is an open source Java library available at
6. Apache Ant version 1.6.5
7. Apache Tomcat version 5.5.20
8. MySQL

• Amazon Access key id and Secret Access Key are the Amazon’s Account info. A connection to Amazon S3 is obtained by using those keys.
• Amazon Simple Storage Service (S3): Amazon Simple Storage Service (S3) is Amazon’s unlimited data storage service and is exposed via a web service interface.
• Bucket: A bucket is simply a container for objects stored in Amazon S3. Every object is contained within a bucket. Bucket is like a the folder on the root directory and any object can be retrieved from the bucket using following url:

To build and deploy the app, following are steps and ant commands:

1. Change the “” in the build folder. Give your Tomcat path and database url and username, password.
2. Change the “” in the WEB-INF.
3. Give your Amazon Access key id and Secret Access Key in “”.
4. Ant mysql-start
5. Ant mysql-prepareSpringAWSDB
6. Ant server-deploy
7. Ant tomcat-start


Home View:
This will display the complete lists of Buckets available in the Amazon’s Account.

After clicking on any bucket name, this view will display all contents available in the bucket


After clicking on “Download”, content file will be downloaded.


Upload Content:

Source code can be found on the following link:
Download Source