A robust, multi-module Jakarta EE 10 banking application, fully containerized using Docker and Docker Compose.
This project demonstrates how to modernize a legacy-style "Big Iron" Java application (EAR packaging) by migrating it to a containerized environment. It solves complex Enterprise startup challenges using a custom orchestration script that guarantees strict ordering between the Database, Connection Pools, and Application Deployment.
- Framework: Jakarta EE 10 (JPA, Hibernate, EJB, Servlet)
- Build Tool: Maven (Multi-module Project)
- Application Server: Payara 6 (Full Profile)
- Database: MySQL 8.0
- Containerization: Docker & Docker Compose
The project follows a classic Enterprise Java architecture packaged as an EAR (Enterprise Archive):
core: Domain models (Entities) and Persistence logic.web: The web presentation layer.service/ejb: Business logic (Account management, Transactions).ear: Final packaging module.
This repository uses a Separation of Concerns strategy, producing two portable artifacts:
-
Database Image (
banking-db):- Based on
mysql:8.0. - The schema (
database.sql) is "baked" directly into the image, ensuring the database is pre-initialized with tables and users upon startup anywhere.
- Based on
-
Application Image (
banking-app):- Based on
payara/server-full. - Contains the compiled EAR file, MySQL JDBC drivers, and a custom Supervisor Script.
- The Supervisor Script (
run_payara.sh) manages the lifecycle to prevent race conditions:- Starts Payara in the background.
- Creates JDBC Connection Pools & Resources via
asadmin. - Verifies the connection with a Ping.
- Deploys the application only after the infrastructure is ready.
- Based on
The Docker setup handles several critical configurations automatically:
- Self-Contained Database: No local volume mounting is required for the schema; it is distributed within the image.
- Driver Injection: The MySQL Connector/J driver is copied into the Payara domain library folder during the build.
- Race Condition Resolution:
- The
docker-composehealthcheckensures Payara waits until MySQL is healthy. - The internal
run_payara.shscript waits for the Admin Console (port 4848) before attempting configuration.
- The
- MySQL 8 Compatibility: The connection pool is configured with
allowPublicKeyRetrieval=trueanduseSSL=falseto support modern MySQL authentication.
You do not need Java, Maven, or SQL files installed. You only need Docker.
-
Create a
docker-compose.yamlfile with the following content:# version: "3.9" services: mysql: image: hasunb/jakarta-ee-multi-module-banking-system-db:latest container_name: bank_mysql restart: always environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: banking_db MYSQL_USER: bank_user MYSQL_PASSWORD: bank_pass healthcheck: test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ] interval: 5s timeout: 5s retries: 10 payara: image: hasunb/jakarta-ee-multi-module-banking-system:latest container_name: bank_payara # restart: always (optional: if the container failed start it start again) depends_on: mysql: condition: service_healthy ports: - "8080:8080" - "4848:4848"
-
Start the application:
docker-compose up
-
Access the application:
- Web App:
http://localhost:8080/Banking-System - Payara Admin Console:
http://localhost:4848(User:admin, No Password)
- Web App:
If you want to modify the code and rebuild the images yourself:
-
Clone the repository:
git clone https://github.com/hasunB/dockerized-jakarta-ee-banking-system.git cd dockerized-jakarta-ee-banking-system -
Build and Run Locally:
docker-compose up --build