This guide provides information for developers who want to download and work with the MicroProfile e-commerce application source code. Each chapter of the tutorial includes practical code examples that demonstrate various MicroProfile features.
The MicroProfile Tutorial includes a comprehensive e-commerce application built with Jakarta EE 10 and MicroProfile 7.1. The application demonstrates real-world use of MicroProfile features through a multi-service architecture that includes catalog, inventory, user, payment, and order services.
The source code for the tutorial is organized by chapter in the code/ directory. Each chapter builds upon the previous one, introducing new MicroProfile features and concepts:
code/
├── chapter02/ # Getting Started
├── chapter03/ # Jakarta EE 10 Core Profile
├── chapter04/ # OpenAPI
├── chapter05/ # Configuration
├── chapter06/ # Health Checks
├── chapter07/ # Metrics
├── chapter08/ # Fault Tolerance
├── chapter09/ # Telemetry
├── chapter10/ # JWT Authentication
├── chapter11/ # REST Client
├── chapter12/ # Graph QL
└── chapter13/ # Reactive MessagingEach chapter directory contains one or more microservices with the following structure:
chapterXX/
├── <service-name>/
│ ├── src/
│ │ ├── main/
│ │ │ ├── java/ # Java source code
│ │ │ ├── liberty/config/ # Open Liberty configuration
│ │ │ └── resources/ # Application resources
│ │ └── test/ # Unit and integration tests
│ ├── pom.xml # Maven build configuration
│ └── README.adoc # Service-specific documentationBefore working with the code, ensure you have the following installed:
-
Java Development Kit (JDK) 21 or later
-
Maven 3.9.12 or later - For building the applications
-
Git - For cloning the repository
We recommend using SDKMAN for managing Java versions, as it makes it easy to switch between different JDK versions.
If SDKMAN is not already installed, follow the official instructions at https://sdkman.io/install/ or run:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"# List available Java versions
sdk list java
# Install JDK 21 (Microsoft build)
sdk install java 21.0.11-ms
# List installed Java versions
sdk list java | grep -E ".*\s+installed"
# Switch to JDK 21 for the current shell session
sdk use java 21.0.11-ms
# Make JDK 21 the default for all sessions
sdk default java 21.0.11-ms
# Verify the current Java version
java -versionVisual Studio Code:
-
Java Extension Pack
-
Language Support for Java by Red Hat
-
Liberty Tools for VS Code
-
AsciiDoc extension (for viewing documentation)
IntelliJ IDEA:
-
Built-in Java and Maven support
-
MicroProfile plugin (available in the marketplace)
-
Liberty plugin (available in the marketplace)
Eclipse:
-
Eclipse IDE for Enterprise Java and Web Developers
-
Liberty Developer Tools
The tutorial uses Maven and the Open Liberty Maven plugin to build and run the application.
To build any microservice, navigate to its directory and run:
mvn clean packageThis command: - Compiles the Java source code - Runs unit tests - Packages the application as a WAR file
The easiest way to run an application is using the Liberty Maven plugin in development mode:
mvn liberty:devDevelopment mode features:
-
Automatically rebuilds and redeploys on code changes
-
Runs tests on demand by pressing Enter
-
Supports hot reload for faster development
-
Provides debugging capabilities
To exit development mode, press Ctrl+C or type q and press Enter.
Once the server is running, you can access the application endpoints. The default configuration typically uses:
-
Host: localhost (or your system hostname)
-
Port: Varies by service (commonly 9080)
For example, for the catalog service in Chapter 3:
http://localhost:9080/catalog/api/productsReplace localhost with your system hostname if accessing from a different machine.
If you need to run multiple services simultaneously or avoid port conflicts, you can change the HTTP port in the Liberty server configuration.
Edit src/main/liberty/config/server.xml:
<httpEndpoint id="defaultHttpEndpoint"
host="*"
httpPort="9080" <!-- Change this port -->
httpsPort="9443" />Most chapters use the Derby embedded database for simplicity. The database configuration is in src/main/resources/META-INF/persistence.xml:
<persistence-unit name="prod" transaction-type="JTA">
<jta-data-source>jdbc/DefaultDataSource</jta-data-source>
<properties>
<!-- JPA and database properties -->
</properties>
</persistence-unit>To add new dependencies, edit the pom.xml file. The tutorial uses Maven for dependency management:
<dependencies>
<!-- Add your dependencies here -->
<dependency>
<groupId>org.example</groupId>
<artifactId>example-library</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>The MicroProfile Tutorial applications use the following technology stack:
-
Jakarta EE 10 - Enterprise Java specifications
-
MicroProfile 7.1 - Cloud-native microservices specifications
-
Maven - Build and dependency management
-
Jakarta RESTful Web Services (JAX-RS) - REST API development
-
Jakarta Persistence (JPA) - Database persistence
-
Jakarta Contexts and Dependency Injection (CDI) - Dependency injection
-
Jakarta Bean Validation - Input validation
-
Jakarta JSON Binding (JSON-B) - JSON serialization
-
Jakarta JSON Processing (JSON-P) - JSON processing
-
MicroProfile Config - Configuration management
-
MicroProfile Health - Health check endpoints
-
MicroProfile Metrics - Application metrics
-
MicroProfile OpenAPI - API documentation
-
MicroProfile JWT - JWT authentication
-
MicroProfile Fault Tolerance - Resilience patterns
-
MicroProfile REST Client - Type-safe REST clients
-
MicroProfile GraphQL - GraphQL based calls
-
MicroProfile Reactive Messaging - Event Driven Architecture and Reactive Messaging using Asynchronous calls
When working with the tutorial code, consider these best practices:
-
Start with Early Chapters: If you’re new to MicroProfile, start with Chapter 2 and progress sequentially.
-
Read the Documentation: Each service includes a README.adoc with specific instructions and explanations.
-
Experiment: The code is designed for learning - modify it, break it, and understand how it works.
-
Follow the Layered Architecture: The code uses a clear separation between resources, services, repositories, and entities.
-
Keep Services Small: Each microservice focuses on a specific business capability.
-
Use DTOs When Appropriate: Don’t expose entity classes directly in REST APIs for complex scenarios.
-
Write Tests: Add unit tests for your changes to ensure they work correctly.
-
Test in Development Mode: Use the interactive testing feature in
mvn liberty:devby pressing Enter. -
Integration Tests: Some chapters include integration tests that verify end-to-end functionality.
Problem: Error message indicates the port is already in use.
Solution:
# Find process using the port (e.g., 9080)
lsof -i :9080
# Kill the process
kill <PID>
# Or change the port in server.xmlProblem: Maven fails to download dependencies or build the project.
Solution:
# Clean Maven cache and rebuild
mvn clean install -U
# Verify Maven is properly configured
mvn -version
# Check your internet connection and proxy settings if behind a firewallAfter setting up your development environment and exploring the code:
-
Run the Examples: Start with Chapter 2 and work through each chapter sequentially
-
Modify the Code: Try adding new features or changing existing functionality
-
Build Your Own Service: Create a new microservice using the patterns learned
-
Integrate Services: Practice calling one service from another using the REST Client
-
Deploy to Production: Learn about deploying MicroProfile applications to cloud platforms
-
MicroProfile: https://microprofile.io
-
Jakarta EE: https://jakarta.ee
If you find issues with the code or have suggestions for improvements:
-
Check existing issues in the GitHub repository
-
Create a new issue with:
-
Clear description of the problem or suggestion
-
Steps to reproduce (for bugs)
-
Expected vs. actual behavior
-
-
Consider submitting a pull request with fixes or enhancements
For documentation improvements, see the Contributors Guide.