Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

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

AWS CLI Credentials Setup: Configure, Verify, and Secure Access

Learn how to configure AWS credentials with the AWS CLI, verify your identity, and understand where credentials are stored. This updated guide also compares profiles, environment variables, and role-based access.

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

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

EC2Deploy and the Cloud Tools Maven Plugin: Architecture, Goals, and Deployment Workflow

This revised guide explains what the 2010 EC2Deploy and Cloud Tools release actually introduced, how its components fit together, and how the Maven goals map to deployment operations on EC2. It also covers what modern teams should verify before relying on this legacy toolchain.

Read More

Cloud Tools Adds Amazon EBS Support: Durable EC2 Storage for Database Workloads

This historical update covers when Cloud Tools introduced Amazon EBS support for EC2 applications, including database-backed deployments. It explains the supported storage modes, the backup/restore flow, and practical command-level equivalents.

Read More

EC2 Key Pairs vs AWS Credentials: Practical Fixes for SSH and Security Group Setup

New EC2 users often confuse AWS API credentials with EC2 SSH key pairs, then get blocked by security group rules. This guide separates each concept and shows repeatable CLI and console steps to get instance access working safely.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x