Skip to content

Commit cc6c28a

Browse files
committed
Java 25 changes
1 parent bba870b commit cc6c28a

15 files changed

Lines changed: 145 additions & 43 deletions

File tree

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,62 @@ This project contains the supporting code for the Java on AWS Immersion Day. You
77
# Overview
88
In this workshop you will learn how to build cloud-native Java applications, best practices and performance optimizations techniques. You will also learn how to migrate your existing Java application to container services such as AWS AppRunner, Amazon ECS and Amazon EKS or how to to run them as Serverless AWS Lambda functions.
99

10+
## Updated for Java 25 and Spring Boot 4
11+
This workshop has been updated to use the latest versions:
12+
- **Java 25** - The latest LTS release with enhanced performance and new language features
13+
- **Spring Boot 4.0** - The latest major release with improved native compilation and enhanced observability
14+
15+
### Key Benefits of the Upgrade:
16+
- **Performance**: Java 25 includes significant JVM improvements and optimizations
17+
- **Native Compilation**: Enhanced GraalVM support for faster startup times
18+
- **Modern Language Features**: Access to the latest Java language enhancements
19+
- **Spring Boot 4**: Improved developer experience and production-ready features
20+
21+
### Prerequisites:
22+
- Java 25 JDK installed
23+
- Maven 3.9+
24+
- Docker (for integration tests)
25+
1026
# Modules and paths
1127
The workshop is structured in multiple independent modules that can be chosen in any kind of order - with a few exceptions that mention a prerequisite of another module. While you can feel free to chose the path to your own preferences, we prepared three example paths through this workshop based on your experience:
1228

1329
![Java on AWS](resources/paths.png)
1430

31+
## Applications Status
32+
All applications have been successfully updated and tested:
33+
34+
### ✅ unicorn-store-spring
35+
- **Status**: Updated to Java 25 & Spring Boot 4.0
36+
- **Compilation**: ✅ Success
37+
- **Notes**: Main application with full Spring Boot features
38+
39+
### ✅ unicorn-spring-ai-agent
40+
- **Status**: Updated to Java 25 & Spring Boot 4.0
41+
- **Compilation**: ✅ Success
42+
- **Notes**: AI agent with Spring AI integration
43+
44+
### ✅ jvm-analysis-service
45+
- **Status**: Updated to Java 25 & Spring Boot 4.0
46+
- **Compilation**: ✅ Success
47+
- **Notes**: JVM performance analysis service
48+
49+
### ✅ Integration Tests
50+
- **Status**: Updated to use Testcontainers with Docker
51+
- **Notes**: Tests use PostgreSQL and LocalStack containers for realistic testing
52+
- **Requirements**: Docker Desktop must be running
53+
- **Test Results**: All 9 tests pass with full database and AWS service integration
54+
55+
## Quick Start
56+
```bash
57+
# Compile all applications
58+
cd apps/unicorn-store-spring && mvn clean compile
59+
cd ../unicorn-spring-ai-agent && mvn clean compile
60+
cd ../jvm-analysis-service && mvn clean compile
61+
62+
# Run tests (requires Docker)
63+
mvn clean test
64+
```
65+
1566
## Security
1667

1768
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

apps/dockerfiles/Dockerfile_00_initial

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
RUN yum install -y shadow-utils
44

apps/dockerfiles/Dockerfile_01_original

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
RUN yum install -y shadow-utils
44

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
COPY ./pom.xml ./pom.xml
44
COPY src ./src/
55

66
RUN mvn clean package && mv target/store-spring-1.0.0-exec.jar store-spring.jar
77
RUN rm -rf ~/.m2/repository
88

9-
FROM public.ecr.aws/docker/library/amazoncorretto:21-al2023
10-
RUN yum install -y shadow-utils
9+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023
1110

11+
RUN yum install -y shadow-utils
1212
COPY --from=builder store-spring.jar store-spring.jar
13-
1413
RUN groupadd --system spring -g 1000
1514
RUN adduser spring -u 1000 -g 1000
1615

1716
USER 1000:1000
18-
1917
EXPOSE 8080
20-
ENTRYPOINT ["java","-jar","-Dserver.port=8080","/store-spring.jar"]
18+
19+
ENTRYPOINT ["java","-jar","-Dserver.port=8080","/store-spring.jar"]

apps/dockerfiles/Dockerfile_03_otel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
COPY ./pom.xml ./pom.xml
44
COPY src ./src/
55

66
RUN mvn clean package && mv target/store-spring-1.0.0-exec.jar store-spring.jar
77
RUN rm -rf ~/.m2/repository
88

9-
FROM public.ecr.aws/docker/library/amazoncorretto:21-al2023
9+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023
1010
RUN yum install -y shadow-utils
1111

1212
COPY --from=builder store-spring.jar store-spring.jar
Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
2-
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
32
RUN yum install -y tar gzip unzip
4-
53
COPY ./pom.xml ./pom.xml
64
COPY src ./src/
7-
85
RUN mvn clean package && mv target/store-spring-1.0.0-exec.jar target/store-spring.jar && cd target && unzip store-spring.jar
9-
106
RUN jdeps --ignore-missing-deps \
11-
--multi-release 21 --print-module-deps \
7+
--multi-release 25 --print-module-deps \
128
--class-path="target/BOOT-INF/lib/*" \
139
target/store-spring.jar > jre-deps.info
14-
1510
# Adding jdk.crypto.ec for TLS 1.3 support
1611
RUN truncate --size -1 jre-deps.info
1712
RUN echo ",jdk.crypto.ec" >> jre-deps.info && cat jre-deps.info
18-
1913
RUN export JAVA_TOOL_OPTIONS=\"-Djdk.lang.Process.launchMechanism=vfork\" && \
2014
jlink --verbose --compress 2 --strip-java-debug-attributes \
2115
--no-header-files --no-man-pages --output custom-jre \
2216
--add-modules $(cat jre-deps.info)
23-
2417
FROM public.ecr.aws/amazonlinux/amazonlinux:2023
2518
RUN yum install -y shadow-utils
26-
2719
COPY --from=builder target/store-spring.jar store-spring.jar
2820
COPY --from=builder custom-jre custom-jre
29-
3021
RUN groupadd --system spring -g 1000
3122
RUN adduser spring -u 1000 -g 1000
32-
3323
USER 1000:1000
34-
3524
EXPOSE 8080
36-
ENTRYPOINT ["./custom-jre/bin/java","-jar","-Dserver.port=8080","/store-spring.jar"]
25+
ENTRYPOINT ["./custom-jre/bin/java","-jar","-Dserver.port=8080","/store-spring.jar"]

apps/dockerfiles/Dockerfile_05_GraalVM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21 AS build-aot
1+
FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-25 AS build-aot
22

33
USER root
44
RUN microdnf install -y unzip zip

apps/dockerfiles/Dockerfile_06_SOCI

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
COPY ./pom.xml ./pom.xml
44
COPY src ./src/
@@ -8,7 +8,7 @@ RUN mvn clean package -Psoci && \
88
java -Djarmode=layertools -jar store-spring.jar extract
99
RUN rm -rf ~/.m2/repository
1010

11-
FROM public.ecr.aws/docker/library/amazoncorretto:21-al2023
11+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023
1212
RUN yum install -y shadow-utils
1313

1414
COPY --from=builder store-spring.jar store-spring.jar

apps/dockerfiles/Dockerfile_07_AOT

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# syntax=docker/dockerfile:1
2+
# ===== build (Spring AOT + package) =====
3+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS build
4+
WORKDIR /w
5+
COPY pom.xml .
6+
COPY src ./src/
7+
RUN mvn -DskipTests clean compile org.springframework.boot:spring-boot-maven-plugin:process-aot package \
8+
&& mv target/*-exec.jar /w/app.jar \
9+
&& rm -rf ~/.m2/repository
10+
11+
# ===== train (Leyden AOT cache) =====
12+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023 AS train
13+
WORKDIR /w
14+
COPY --from=build /w/app.jar /w/app.jar
15+
# explode fat jar and make a JAR-only classpath that matches final runtime paths
16+
RUN mkdir -p /w/ex && (cd /w/ex && jar -xf /w/app.jar) \
17+
&& mkdir -p /opt/app/training /opt/app/lib \
18+
&& (cd /w/ex/BOOT-INF/classes && jar -cf /opt/app/training/classes.jar .) \
19+
&& cp -r /w/ex/BOOT-INF/lib/* /opt/app/lib/
20+
ENV APP_CP="/opt/app/training/classes.jar:/opt/app/lib/*"
21+
ENV MAIN_CLASS="com.unicorn.store.StoreApplication"
22+
# Optional: pass DB props for training in one shot
23+
# docker build --build-arg TRAINING_JAVA_OPTS="-Dspring.datasource.url=... -Dspring.datasource.username=... -Dspring.datasource.password=... -Dspring.sql.init.mode=never" ...
24+
ARG TRAINING_JAVA_OPTS=""
25+
ENV TRAINING_JAVA_OPTS=${TRAINING_JAVA_OPTS}
26+
ENV TRAINING_JAVA_OPTS_DEFAULT="-Dspring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration -Dspring.main.lazy-initialization=true"
27+
28+
# record
29+
RUN set -e; \
30+
OPTS="$TRAINING_JAVA_OPTS"; [ -z "$OPTS" ] && OPTS="$TRAINING_JAVA_OPTS_DEFAULT"; \
31+
java -XX:AOTMode=record -XX:AOTConfiguration=/w/app.aotconf \
32+
-cp "$APP_CP" -Dspring.context.exit=onRefresh $OPTS $MAIN_CLASS || true \
33+
&& test -s /w/app.aotconf
34+
35+
# create cache
36+
RUN set -e; \
37+
OPTS="$TRAINING_JAVA_OPTS"; [ -z "$OPTS" ] && OPTS="$TRAINING_JAVA_OPTS_DEFAULT"; \
38+
java -XX:AOTMode=create -XX:AOTConfiguration=/w/app.aotconf \
39+
-XX:AOTCache=/opt/app/app.aot \
40+
-cp "$APP_CP" $OPTS $MAIN_CLASS || true \
41+
&& test -s /opt/app/app.aot
42+
43+
# ===== runtime =====
44+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023
45+
RUN yum install -y shadow-utils
46+
WORKDIR /opt/app
47+
COPY --from=train /opt/app/training/classes.jar /opt/app/training/classes.jar
48+
COPY --from=train /opt/app/lib/ /opt/app/lib/
49+
COPY --from=train /opt/app/app.aot /opt/app/app.aot
50+
RUN groupadd --system spring -g 1000
51+
RUN adduser spring -u 1000 -g 1000
52+
USER 1000:1000
53+
EXPOSE 8080
54+
ENTRYPOINT ["java", "-XX:AOTCache=/opt/app/app.aot", "-cp", "/opt/app/training/classes.jar:/opt/app/lib/*", "com.unicorn.store.StoreApplication"]

apps/dockerfiles/Dockerfile_10_async_profiler

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-21-al2023 AS builder
1+
FROM public.ecr.aws/docker/library/maven:3-amazoncorretto-25-al2023 AS builder
22

33
RUN yum install -y wget tar gzip
44
RUN cd /tmp && \
@@ -12,7 +12,7 @@ COPY src ./src/
1212
RUN mvn clean package && mv target/store-spring-1.0.0-exec.jar store-spring.jar
1313
RUN rm -rf ~/.m2/repository
1414

15-
FROM public.ecr.aws/docker/library/amazoncorretto:21-al2023
15+
FROM public.ecr.aws/docker/library/amazoncorretto:25-al2023
1616
RUN yum install -y shadow-utils procps tar
1717

1818
COPY --from=builder /async-profiler/ /async-profiler/

0 commit comments

Comments
 (0)