Run Java EE app on EC2 - java

Can anyone point me to the steps/resources that describe:
How to deploy a Java EE app on amazon-EC2
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)

First check this out if you haven't already ran through it:
http://docs.aws.amazon.com/gettingstarted/latest/awsgsg-intro/intro.html
it'll give you an idea of how it all works.
With regard to running a Java EE app on EC2, you have a couple of choices - but they generally come down to the following recipe:
Start an instance
Install a Java EE application server (tomcat/glassfish/websphere/...)
Install your application (war/ear) into the application server
Now you can bundle the above into an ebs ami, or you can write a script (bash/sh/tcl) which applies those changes when your instance starts (which i prefer). The scripts allow you to modify what gets installed/started/moved around without having to rebundle your instance.
There's some great resources here: http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=100
Hope that helps.

How to deploy a Java EE app on amazon-EC2
You still deploy to an application server so it isn't really different. If you have more specific questions, please clarify. But have a look at Running JEE applications on Amazon EC2 and How to deploy a java web application on an ec2 instance.
Maintain changes to the meta-data of the app server (deploy new applications) after an instance reboot (probably using amazon-ebs)
If you use Amazon EBS, then you don't need to worry, Amazon EBS volumes are off-instance storage that persists independently from the life of an instance.

The Amazon AWS's newly Launched Elastic BeanStalk is here to resolve you concerns.
You can deploy Java EE apps on Amazon Ec2 instances via Bean Stalk. All you need to do is create a new applications and create a environment in it and add you WAR file for deploying, AWS has its own version of Tomcat 6/7 with open JDK which can be customized to Sun JDK if required.
Therefore Amazon offers complete Deployment tool to start using your app by just deploying in BeanStalk. BeanStalk offer Auto Scaling & Elastic Load balancing and a lots more to customize your application Environment.

If you start an ebs-booted instance, you do not need to care about persistency after a reboot (see http://aws.amazon.com/about-aws/whats-new/2009/12/03/amazon-ec2-instances-now-can-boot-from-amazon-ebs/)
Concerning the deployment of Java EE, I don't see any difference to deploying it on a non-virtual OS.

Boxfuse supports deploying Java EE applications using either Tomcat, TomEE Web Profile or TomEE Plus to AWS with a single command
boxfuse run mytomeeapp-1.0.war -env=prod
This will create an image, provision all necessary AWS infrastructure and launch the instances. It supports blue/green zero downtime updates with Elastic IPs and ELBs.
You can find a tutorial here: https://boxfuse.com/blog/javaee-aws.html
You don't have to worry about maintaining changes to the meta-data as all instances are immutable and contain all necessary app server info.
Disclaimer: I am the founder and CEO of Boxfuse

Related

How to upload Servlet/JSP website through Amazon Web Services?

I am working on a Servlet/JSP project and I want to host it on aws.amazon.com. I have already signed up for Amazon Web Services and after signing in this page opens up and I have no idea what to do or which option to select.
I think AWS provides a lot of customization with a lot advanced technical options to choose from, but this is difficult for beginners who just want to make their site running.
My project will use these:-
JSP/Servlets
CSS
MySQL
Struts2
Tomcat WebServer
I would suggest these approaches to study:
Elastic BeanStalk - This is AWS simply hosting model. If you're not IT savy you should pursue this approach
EC2 with MySQL RDS - In this case you'll create a Virtual Machine(s) (EC2) install Tomcat and other dependencies and deploy your app. You'll then use RDS to store your data (which is MySql as a service)
EC2 only - YOu'll do the same as 2. but install your own instance of MySql. There may be AMI's offered that you can provision that will meet your application requirements.
Other reading:
Route53 if your going to use AWS for your domain records
Elastic Load Balancing if your going to need High Availability
Elastic Block Store if you want persistent disks accross VMs
Network Security Groups to secure your VMs (for 1. and 2.)
Virtual Private Cloud for additional security
CloudFormation if you want to automate provisioning
There are many articles on: AWS Architecture
There is a eclipse plugin for Amazon web services.
The AWS Toolkit provides an AWS Java web project template for use in Eclipse. The template creates a web tools platform (WTP) dynamic web project that includes the AWS SDK for Java in the project's classpath. Your AWS account credentials and a simple index.jsp file are provided to help you get started. The following instructions assume you have installed both the Eclipse IDE for Java EE Developers and the AWS Toolkit plug-in. For more information, see Setting Up the AWS Toolkit for Eclipse.
Also check this & this
I would recommend 1st approach using Beanstalk to deploy your jsp application. There you are going to leverage all the advantages of AWS like load balancing, auto scaling, ddb and DW support and many other technologies. With Beanstalk you setup dev environment on your local machine and deploy the changes in AWS and once setup is done you are done...
May be you will need to spend some time on migrating from MySQL but that will be work on longer duration when you are going to have lot of users.

deploy java web project without deploying JDK and tomcat on windows azure

Can we deploy a java project on windows azure without uploading JDK and Tomcat on storage in windows azure? If yes, please provide me steps how to do it.
I made a project as provided in windows azure create a sample application in Java.
But at time i have to create a cloud service, I am supposed to deploy JDK and tomcat which totals around 100-130 MB. Isn't there any solution so that we should deploy cloud service and not JDK and tomcat.
Azure VM images do not include the JDK or any of the Java web servers (Tomcat, Jetty, etc.). You need to get them, from somewhere.
So... when building a Java app via Eclipse and related Cloud Service template, there's a startup script that bootstraps your worker role instances. This involves grabbing the SDK and web server (Tomcat, Jetty, etc.) from somewhere and placing it on your instance's disk. Since you're using Cloud Services (worker role in this case), the OS disks are stateless: Each time a new VM instance spins up, it starts fresh, and you're responsible for setting things up (via startup script).
So: You need to set up your SDK and web server. You can either bundle these with your deployment package or download them from somewhere. The former increases the deployment package size by quite a bit (maybe 100MB?). The latter requires you to download the bits from somewhere. You can either download from somewhere like Oracle (which requires you to go through a license agreement each time), or from your own storage account (which is very fast, as long as it's in the same region as your code deployment). Further: being in the same data center, there are no bandwidth charges when downloading stuff to your worker role instances.
The current Eclipse plugin has a setting for your worker role, where you specify blob storage for your JDK and web server. By doing this, it's basically a one-time setup (except when it's time to upgrade the JDK or Tomcat/Jetty version, and then you'll need to re-upload to blob storage). Once these bits are in blob storage, you only need to include your Java classes in your deployment package.

How to automatically upgrade a Java application during its startup?

I have a Java 1.6 application deployed on several machines (~ 30), and started as a Windows service.
My main problem concerns the maintenance of these deployed artifacts: if I develop a new version of this application, I don't want to manually redeploy it on every machine.
Ideally, when the Windows service is starting, it checks on a remote server if an update exists, and if it is found, then it upgrades the application.
Note that it is acceptable that after this upgrade the service requires to be restarted again.
This mechanism can be compared to the Maven snapshot verification: if there is a newer version of a SNAPSHOT version on a remote repository, then Maven download it before running it.
Note that the application itself will be deployed on a Maven repository (in our case Nexus), so the check for an update will be done against this Nexus instance.
What are my technical solutions to implement such an automatically application update?
Do not hesitate to ask me more details about technical information or about the context...
Thanks.
Edit: As stated by Peter Lawrey, I can use Java Web Start. However, how can I integrate JWS within a Java application that is run as a Windows service?
I would look at Java Web Start
A common technique for this is to use a launcher. The steps are something like this:
Start the launcher.
The launcher checks to see if the application should be updated. If yes, the launcher updates the application (I think of this as "the update step").
After the update step, the launcher runs the application.

customize Elastic Beanstalk instances

We are deploying a java web application in Elastic Beanstalk. The Beanstalk by default provides Redhat instances with Tomcat7 & openjdk. But i want to customize the instances so that i can use Sunjdk.
Followed the steps as mentioned here, I launched a new instance from EC2 & installed sun jdk, tomcat7 and created a custom AMI of the instance and provided its ID in Custom AMI id field in edit Environment configuration in BeanStalk. But my Environment Health status is changing to RED, and the application is not deployed. Can you please suggest me a solution for this.
I have done exactly what you want to do, and am happy to report that it works. In my first attempts I encountered the same issue. Make sure that you:
Create your custom AMI from a running instance of Amazon's beanstalk AMI that you manually launch from EC2, NOT one that was launched from starting your application through beanstalk. This is very important, as Flashing a beanstalk launched EC2 instance won't work!!
install Sun's Java as per these instructions, to make sure all the environment and symbolic links are correct. https://forums.aws.amazon.com/message.jspa?messageID=251168#251168
be patient, as I found for some reason Tomcat takes longer to spin up than with the default OpenJDK config.
If you still can't get it, make sure you check the logs in /opt/tomcat7/logs/catalina.out - I hit a mysterious VerifyException that was resolved by uploading a new .jar to the environment, and I also ran out of permgen space almost immediately, which was resolved by upping the values in the 'Container' configuration area of the beanstalk 'edit configuration'.

How to deploy a Java EE application in the Amazon cloud?

Here's the thing: I need to take a certain Java EE web app and deploy it to Amazon EC2 (which I will need to setup first) starting next month (using the http://aws.amazon.com/free/faqs/ AWS Free Tier Usage - hope it supports Tomcat + MySQL/PostgreSQL).
The problem: I have never ever deployed a Java EE app (not even a normal one on a dedicated hosting) nor have I setup an Amazon EC2 enviorment.
Are there any, idiot proof preferably, tutorials/how-to's/whatever on doing it from the very beginning (signing up to Amazon) till the very end (when your app is all up and running)?
I did find some tutorials on how to setup an Amazon EC2 instance, how to normally deploy a Java EE app but what I'm looking for is a single tutorial putting it all together.
Start with an Ubuntu AMI. Then install tomcat. Now put the WAR file of your J2EE app where tomcat can see it. You can use the AWS console to start/stop your machines, configure firewall rules that allow you to access port 80, etc. There won't be a step by step guide telling you exactly what to do, welcome to being a programmer.
Once we have the instance (like Ubuntu) running http://youtu.be/hJRSti6DsJg then, installs Glassfish (Java EE server) and configure it to work with Java EE. It depends more of the instance itself (Ubuntu) than EC2 Amazon... here a nice video (how to install Glashfish in Ubuntu + Netbeans config) http://youtu.be/CKuoDm6bqRM
Note:
Keep in mind both videos are a little old (may some adjustments are necessary)
The videos are indirectly related. But my point is: there isn't much info about Amazon AWS and Java EE, but there are a lot info about Amazon AWS and Linux, and Linux and Java EE.
Update
You can try Amazon Beanstalk (Deployment & Management) integrated with Netbeans (without Glashfish?) http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.html
SSH to Elastic Beanstalk instance
http://aws.amazon.com/java/ (Amazon + Java)
Boxfuse now supports deploying Java EE applications using either Tomcat, TomEE Web Profile or TomEE Plus to AWS with a single command
boxfuse run mytomeeapp-1.0.war -env=prod
This will create an image, provision all necessary AWS infrastructure (AMIs, security groups, auto-scaling groups, launch configurations, ELBs, Elastic IPs, ...) and launch the instances. It supports blue/green zero downtime updates with Elastic IPs and ELBs.
You can find a tutorial here: https://boxfuse.com/blog/javaee-aws
Disclaimer: I am the founder and CEO of Boxfuse

Categories