Skip to content

Commit 2ecb995

Browse files
galiachengallxiaomajguoyiliuTofangjian0423
authored
Add a sample to showcase migrating a legacy Java EE Ant project to a Jakarta EE 10 Maven project (#39)
* Update README * add execution permisson to shell scripts Signed-off-by: Jianguo Ma <[email protected]> * worker doesn't listen to port 8081 Signed-off-by: Jianguo Ma <[email protected]> * clean before starting web/worker apps Signed-off-by: Jianguo Ma <[email protected]> * update readme Signed-off-by: Jianguo Ma <[email protected]> * add dev container config Signed-off-by: Jianguo Ma <[email protected]> * fix typo in readme Signed-off-by: Jianguo Ma <[email protected]> * add diff (#16) * add formula source (#14) * migrate rabbitmq to service bus (#18) * delete the new project and diff file (#19) * add open liberty sample * add mybatis, jackson, ServletFilter, cert * refactor, use ibatis instead of mybatis * jar location update * fix dep * run the app with docker * use java 17 * the application is working now. * add spring student home * remove helloworld servlet * improve * add doc * add description * update screenshot * rename project * clean up * remove version specification from docker-compose.yml * update screenshot * format image display in README.md for better alignment * adjust image width in README.md for better alignment * update Java version requirement to 11 in README.md and manual-setup.md * align image to the left in README.md for better presentation * Add new sample for Student Web App using Jakarta EE and update description for existing sample * Rename back. * Update README.md to correct directory name for Student Web App * Fix link formatting for Student Web App in README.md * Refactor README.md and add getting-started.md for clearer migration instructions and setup guidance * add migration steps * Proposed edits to README * Clarify the extension version * Update README.md to correct VS Code extension version and add commit instruction * add libs * rename package name * Remove CommonHttpServletFilter and MyBatisUtil classes * Update resource paths in XML configuration files to reflect new package structure --------- Signed-off-by: Jianguo Ma <[email protected]> Co-authored-by: Menghua Xiao <[email protected]> Co-authored-by: Jianguo Ma <[email protected]> Co-authored-by: Yi Liu <[email protected]> Co-authored-by: fangjimmy <[email protected]> Co-authored-by: Haixia Cheng <[email protected]> Co-authored-by: Ed Burns <[email protected]>
1 parent b520a0d commit 2ecb995

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1956
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
- [asset manager](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/asset-manager) : This is a complete workshop with an end-to-end scenario that migrates an app to Azure using predefined and custom formulas. After the migration, the app will run on Azure Container Apps and interact with Auzure Blob, Azure Service Bus and Azure Database for PostgreSQL.
1010

11-
-[Todo Web API with Oracle Database](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/todo-web-api-use-oracle-db) A To-do application using Oracle database for storage. It leverages Oracle-specific SQL features and data types, for instance, VARCHAR2. This sample migrates the application to use Azure Database for PostgreSQL instead.
11+
- [Todo Web API with Oracle Database](https://github.com/Azure-Samples/java-migration-copilot-samples/tree/main/todo-web-api-use-oracle-db) A To-do application using Oracle database for storage. It leverages Oracle-specific SQL features and data types, for instance, VARCHAR2. This sample migrates the application to use Azure Database for PostgreSQL instead.
12+
13+
- [Student Web App - Jakarta EE](jakarta-ee/student-web-app) A Java EE web application running on Open Liberty with a hybrid architecture that supports both traditional servlets and Spring MVC. The application manages student profiles with CRUD operations and demonstrates migrating from Ant to Maven and Java EE to Jakarta EE.
1214

1315
## Branches
1416

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
target/
2+
build/
3+
dist/
4+
*.war
5+
6+
# IDE files
7+
.idea/
8+
*.iml
9+
.vscode/
10+
/bin/
11+
.project
12+
.classpath
13+
.settings/
14+
15+
# Local configuration files (contain environment-specific paths)
16+
local.properties
17+
liberty_config/server.env
18+
19+
# Compile-time dependencies (can be downloaded)
20+
compile-lib/*.jar
21+
22+
# Docker files
23+
mysql-connector/
24+
25+
# OS files
26+
.DS_Store
27+
Thumbs.db
28+
29+
# Log files
30+
*.log
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM open-liberty:25.0.0.7-kernel-slim-java17-openj9
2+
3+
# Copy Liberty configuration
4+
COPY --chown=1001:0 liberty_config/server-docker.xml /config/server.xml
5+
COPY --chown=1001:0 liberty_config/server-docker.env /config/server.env
6+
7+
# Copy application
8+
COPY --chown=1001:0 dist/OpenLibertyApp.war /config/apps/
9+
10+
# Create directories for libraries
11+
RUN mkdir -p /opt/ol/wlp/usr/shared/resources/mysql
12+
13+
# Copy MySQL connector for JDBC driver
14+
COPY --chown=1001:0 mysql-connector/mysql-connector-j-8.0.33.jar /opt/ol/wlp/usr/shared/resources/mysql/
15+
16+
# Configure Liberty features
17+
RUN features.sh
18+
19+
# Expose ports
20+
EXPOSE 9080 9443
21+
22+
# Set environment variables for Docker environment
23+
ENV WLP_USER_DIR=/opt/ol/wlp/usr \
24+
SERVER_NAME=defaultServer \
25+
MYSQL_LIB_DIR=/opt/ol/wlp/usr/shared/resources/mysql \
26+
LIBERTY_SERVER_DIR=/config \
27+
KEYSTORE_LOCATION=/config/resources/security/key.p12 \
28+
KEYSTORE_PASSWORD=defaultPassword \
29+
TRUSTED_KEYSTORE_LOCATION=/config/resources/security/trust.p12 \
30+
TRUSTED_KEYSTORE_PASSWORD=defaultPassword \
31+
LTPA_KEY_FILE_SFA=/config/resources/security/ltpa.keys \
32+
LTPA_KEY_PASSWORD_SFA=defaultPassword \
33+
JDBC_DRIVER_CLASS=com.mysql.cj.jdbc.Driver
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Migrate a legacy Java EE Ant project to a Jakarta EE 10 Maven project
2+
3+
This workshop guides you through migrating a legacy Java EE Ant project to a Jakarta EE 10 Maven project. After completing the workshop, the project will be fully migrated from Java EE to Jakarta EE 10, upgraded from Spring Framework 5.3.39 to 6.2.x, and ready to build with Maven.
4+
5+
## About this Sample Project
6+
7+
A Java EE web application running on Open Liberty with a hybrid architecture that supports both traditional servlets and Spring MVC. The application manages student profiles with CRUD operations and demonstrates migrating from Ant to Maven and Java EE to Jakarta EE.
8+
9+
For the project architecture, see [project details](doc/architecture.md).
10+
For how to start this project, see [getting started](doc/getting-started.md)
11+
12+
## Prerequisites
13+
14+
- **Java 17** or higher
15+
- **Apache Ant**, tested version: `1.10.14`.
16+
- **Maven**, tested version: `3.8.7`.
17+
- **Docker & Docker Compose** (Optional, for running the sample application)
18+
- [Visual Studio Code](https://code.visualstudio.com/download)
19+
- [VS Code Extension: GitHub Copilot App Modernization](https://marketplace.visualstudio.com/items?itemName=vscjava.migrate-java-to-azure). Make sure the version is higher than `1.2.1`; if not, switch to a pre-release version.
20+
- This extension depends on [VS Code Extension: GitHub Copilot App Modernization – Upgrade for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-upgrade). Both extensions will be installed automatically when you install **GitHub Copilot App Modernization**.
21+
22+
## Assess the Project
23+
24+
Please follow the steps below to assess and detect the Eclipse/Ant project:
25+
26+
1. Open [student-web-app](jakarta-ee/student-web-app) in VSCode.
27+
28+
1. Click **GitHub Copilot app modernization for Java** from the left side tool bar.
29+
30+
Click the `Toggle Chat` icon on the top, select `Agent` mode. If the **reload button** (looks like an arrow going counter clockwise) appears at the bottom, click it to reload the tools registration. This is only required the first time you install the extensions.
31+
32+
![assessment-start](assets/assessment-start.png)
33+
34+
1. Click **Run Assessment** button from the **Assessment** section on the left side view. It will open GitHub Copilot Chat window at the right side, and start to assess the project with the predefined prompt.
35+
36+
1. Interact with Copilot in the chat window and select **Continue** to proceed whenever you're ok with the actions suggested by the Copilot.
37+
38+
1. After the assessment is done, an **Assessment Report** will be generated and opened in the editor. From the bottom of the report, you can see **Build Tool (Ant)** in section **Java Modernization**, and associated action **Migrate** to migrate the project to Maven project.
39+
40+
![assessment-ant-to-maven-solution](assets/assessment-ant-to-maven-solution.png)
41+
42+
## Convert Ant project to Maven project
43+
44+
Now you can convert the Ant project to Maven project.
45+
46+
1. Select Action **Migrate** associated with **Build Tool (Ant)**, and start the migration with the predefined prompt. We recommend using the LLM model **Claude Sonnet 3.7** for the migration.
47+
48+
![convert-ant-to-maven](assets/convert-ant-to-maven.png)
49+
50+
1. Interact with Copilot in the chat window and select **Continue** to proceed whenever you're ok with the actions suggested by the Copilot.
51+
52+
If you see the request from Copilot to ask you confirm the migration plan, please review and manually confirm the migration plan before proceeding. For example, input `Confirm` in the chat box and click `Send`.
53+
54+
1. After the migration is complete, select **Keep** for changed files.
55+
56+
1. Commit changes if they have not been committed.
57+
58+
## Assess and detect the legacy Java EE and Spring Framework project
59+
60+
Please follow the similar steps before to assess and detect the legacy Java EE and Spring Framework project:
61+
62+
1. Select **GitHub Copilot app modernization for Java** from the left side tool bar.
63+
1. Select **Run Assessment** from the **Assessment** section. It will open GitHub Copilot Chat window at the right side, and start to assess the project with the predefined prompt.
64+
1. Interact with Copilot in the chat window and select **Continue** to proceed whenever you're ok with the actions suggested by the Copilot.
65+
1. After the assessment is done, an **Assessment Report** will be generated and opened in the editor. From the bottom of the report, you can see **Framework Upgrade (Java EE/Jakarta EE)** and **Framework Upgrade (Spring Framework)** in section **Java Modernization**, and associated action **Upgrade** to upgrade the project.
66+
67+
## Upgrade the Project to Jakarta EE 10 and Spring Framework 6.x
68+
69+
Now you can upgrade the project. In this workshop, you select to upgrade Spring Framework version as it will also upgrade dependent Java EE version.
70+
71+
1. Select Action **Upgrade** associated with **Upgrade Spring Framework Version**, and start the upgrade with the predefined prompt. Recommend to use LLM model **Claude Sonnet 3.7** for the migration.
72+
1. Interact with Copilot in the chat window and select **Continue** to proceed whenever you're ok with the actions suggested by the Copilot.
73+
1. After the migration is complete, select **Keep** if there are any changed files.
74+
75+
There is an Upgrade Summary generated, review and do any follow-up actions based on your needs.
76+
77+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:context="http://www.springframework.org/schema/context"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans
6+
http://www.springframework.org/schema/beans/spring-beans.xsd
7+
http://www.springframework.org/schema/context
8+
http://www.springframework.org/schema/context/spring-context.xsd">
9+
10+
<!-- Enable component scanning -->
11+
<context:component-scan base-package="org.sample.azure.student.coreft.service"/>
12+
<context:component-scan base-package="org.sample.azure.student.coreft.dao"/>
13+
14+
<!-- Service and DAO beans will be auto-discovered -->
15+
16+
</beans>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)