MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Deploying Java EE on Amazon EC2 with EC2Deploy: Workflow, Script, and Modern Lessons

Originally published on 2010-03-10; fully revised and updated.

This article explains a classic pattern for running Java EE applications on Amazon EC2 using a Groovy framework called EC2Deploy. If you maintain legacy deployment automation or want to understand early cloud-era deployment design, this walkthrough shows the end-to-end flow: infrastructure launch, database and app server setup, WAR deployment, load testing, and environment teardown.

Why this approach mattered for Java EE teams

The original post addressed a real pain point: performance and environment testing required hardware that was expensive and slow to obtain. EC2 made on-demand servers possible, and EC2Deploy wrapped that capability into a developer-friendly API for multi-node test environments.

The source article also referenced then-current EC2 pricing and server-count limits, plus selectable server types. Treat those figures as historical context, not current AWS pricing or quotas.

EC2Deploy workflow and architecture

At a high level, EC2Deploy reads AWS properties, builds a cluster specification, starts EC2 instances, configures MySQL/Tomcat/Apache, deploys the application, runs JMeter tests, and then stops the instances.

flowchart TD
    A[Groovy test script] --> B[Load aws.properties]
    B --> C[Build ClusterSpec]
    C --> D[Call cluster.start]
    D --> E[Launch EC2 instances]
    E --> F[Init MySQL master and slave]
    F --> G[Upload DML and WAR to S3 cache]
    G --> H[Deploy app on Tomcat]
    H --> I[Configure Apache load balancer]
    I --> J[Run cluster.loadTest with JMeter]
    J --> K[Collect CPU latency throughput report]
    K --> L[Call cluster.stop]

Core API objects and methods

The original code uses a small set of objects and fluent methods to describe both infrastructure and application behavior.

Object or methodRole in the workflow
AWSProperties(“/path/to/aws.properties”)Loads AWS credentials and AMI-related properties.
new EC2(awsProperties)Creates the EC2 client wrapper used by EC2Deploy.
ClusterSpec.schema(…)Defines DB schema name, user/password map, and DML scripts.
ClusterSpec.slaves(1)Specifies the number of MySQL slave nodes.
ClusterSpec.tomcats(1)Specifies the number of Tomcat nodes.
ClusterSpec.webApp(explodedWar, “ptrack”)Declares exploded WAR path and context root.
ClusterSpec.catalinaOptsBuilder(…)Builds Tomcat JVM and app properties, including DB host wiring.
cluster.start()Provisions instances and performs configuration/deployment steps.
cluster.loadTest(“…SimpleTest.jmx”, [1,2])Runs JMeter tests at multiple thread counts.
cluster.stop()Stops the EC2 instances when testing is complete.

Annotated Groovy example

The following script is a cleaned-up version of the original example, preserving the same structure and intent.

class ClusterTest extends GroovyTestCase {
  void testSomething() {
    AWSProperties awsProperties = new AWSProperties("/path/to/aws.properties")
    def ec2 = new EC2(awsProperties)

    def explodedWar = "/path/to/projecttrack/webapp/target/ptrack"

    ClusterSpec clusterSpec = new ClusterSpec()
      .schema("ptrack", ["ptrack": "ptrack"], [
        "src/test/resources/testdml1.sql",
        "src/test/resources/testdml2.sql"
      ])
      .slaves(1)
      .tomcats(1)
      .webApp(explodedWar, "ptrack")
      .catalinaOptsBuilder({ builder, databasePrivateDnsName ->
        builder.arg("-Xmx500m")
        builder.prop("com.sun.management.jmxremote")
        builder.prop("com.sun.management.jmxremote.port", 8091)
        builder.prop("com.sun.management.jmxremote.authenticate", false)
        builder.prop("com.sun.management.jmxremote.ssl", false)
        builder.prop("ptrack.application.environment", "ec2")
        builder.prop("log4j.configuration", "log4j-minimal.properties")
        builder.prop("jdbc.db.server", databasePrivateDnsName)
      })

    SimpleCluster cluster = new SimpleCluster(ec2, clusterSpec)
    cluster.start()
    cluster.loadTest("/path/to/functionalTests/jmeter/SimpleTest.jmx", [1, 2])
    cluster.stop()
  }
}Code language: JavaScript (javascript)

What happens during cluster.start()

  • 1) Launch EC2 instances from the configured appliance AMI.
  • 2) Initialize the MySQL master database.
  • 3) Create the MySQL slave.
  • 4) Create schema and users.
  • 5) Run DML scripts.
  • 6) Cache deployment artifacts in Amazon S3.
  • 7) Deploy web applications on each Tomcat node.
  • 8) Configure Apache to balance traffic across Tomcat nodes.

In the original description, DML files were cached in a bucket named tmp–dml, and web apps were cached in -tmp-war to avoid repeatedly uploading unchanged files.

Running JMeter load tests with thread ramps

EC2Deploy can execute a JMeter plan multiple times using different thread counts. In the source example, it runs once with one thread and then with two threads.

cluster.loadTest("/path/to/functionalTests/jmeter/SimpleTest.jmx", [1, 2])Code language: JavaScript (javascript)

Per the original article, each run produced metrics including CPU utilization, average response time, and throughput.

EC2Deploy-era pattern vs common modern alternatives

Need in this workflowEC2Deploy-era implementationCommon modern option
Provision test infrastructureGroovy wrapper around EC2 APIsTerraform or AWS CloudFormation
Configure node software stackCustom appliance AMI and startup logicImmutable images plus config automation
Distribute deployment artifactsS3 cache buckets for DML and exploded WAR filesArtifact repositories and object storage pipelines
Run load tests programmaticallyJMeter invoked by cluster.loadTest()JMeter in CI/CD jobs or dedicated test runners
Tear down temporary environmentscluster.stop()Automated destroy stages in CI/CD

Common pitfalls and best practices

  • Do not reuse historical EC2 price or quota assumptions for planning.
  • Keep credentials out of source-controlled property files; use secret management.
  • Treat performance environments as ephemeral and automate full teardown to control cost.
  • Validate old S3 bucket naming and permissions against current security policies.
  • Prefer reproducible infrastructure definitions over long-lived manually tuned instances.

Historical note preserved from the source: EC2Deploy and an associated Maven plugin were announced as available in this post: EC2Deploy and the Cloud Tools Maven plugin are now available.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Wetty – How to Install & Access Wetty (Web-based SSH) on AWS EC2 linux to access using browser

Wetty is a web-based terminal. It runs a small Node.js server that opens an SSH session and streams it to your browser over WebSockets, so you can…

Read More

Kubernetes Ingress Controller using Path-Based Routing: Complete Hands-On Lab with Calico VXLAN

Scope: Self-managed Kubernetes on two AWS EC2 Ubuntu nodes; install the community ingress-nginx v1.15.1 bare-metal/NodePort manifest, repair cross-node Calico networking, deploy two NGINX versions behind ClusterIP Services, configure path-based routing…

Read More

Automating Jenkins Job Configuration: Job DSL, Multibranch, Job Generator, and JJB

Manually creating many Jenkins jobs is slow and error-prone. This guide compares the main automation options and shows practical jobs-as-code examples for repeatable setup.

Read More

Provision an AWS EC2 Instance with Chef (Legacy ChefDK Workflow)

A practical, step-by-step walkthrough for provisioning an AWS EC2 VM using the classic ChefDK and chef-provisioning approach. Includes workflow, commands, recipe examples, and validation checks for legacy environments.

Read More

Gradle Training Curriculum: Hands-On Learning Path for Build and DevOps Engineers

A revised, practical Gradle training guide based on the original course outline. It maps the agenda to hands-on labs, CI workflow, and team-ready build practices.

Read More

EC2 Boot from EBS Explained: Architecture, Trade-offs, and an AWS CLI Workflow

Booting Amazon EC2 instances from Amazon EBS was a major shift from ephemeral root disks to persistent root volumes. This guide explains what changed, why it mattered, and how to use the model safely in modern operations.

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
27 days ago

Running Java EE applications on Amazon EC2 requires more than getting the server to start successfully. Teams should configure security groups carefully, keep credentials out of code, and monitor CPU, memory, and application logs. A repeatable deployment process also helps keep test and production environments consistent. Before launch, test recovery steps and confirm that backups protect important application data. These practices improve reliability and make cloud-hosted Java applications easier to maintain.

1
0
Would love your thoughts, please comment.x
()
x