Migrate from Java 8 to Java 21 with Jakarta EE 10#2
Migrate from Java 8 to Java 21 with Jakarta EE 10#2devin-ai-integration[bot] wants to merge 2 commits intomasterfrom
Conversation
- Update parent pom.xml: compiler source/target to 21, add maven.compiler.release=21 - Migrate javax.servlet:javax.servlet-api to jakarta.servlet:jakarta.servlet-api:6.0.0 - Migrate javax.enterprise:cdi-api to jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1 - Upgrade maven-war-plugin from 2.5 to 3.4.0 - Replace jetty-maven-plugin 9.x with jetty-ee10-maven-plugin 12.0.14 - Replace weld-servlet 2.x with weld-servlet-shaded 5.1.2.Final (CDI 4.0) - Update web.xml and web-overwrite.xml to Jakarta EE 10 namespace (version 6.0) - Update jetty-env.xml and jetty-context.xml for Jetty 12 EE10 classes - Migrate all Java imports from javax.* to jakarta.* (servlet, inject, enterprise) - Update README files with Java 21 and current dependency versions Co-Authored-By: Jerry Oliphant <jerry.oliphant@cognition.ai>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| <Set name="hiddenClassMatcher"> | ||
| <Call name="exclude"> | ||
| <Arg> | ||
| <Array type="java.lang.String"> | ||
| <Item>org.eclipse.jetty.ee10.servlet.DecoratingListener</Item> | ||
| </Array> | ||
| </Arg> | ||
| </Call> | ||
| </Set> |
There was a problem hiding this comment.
🔴 <Set> used instead of <Get> in jetty-context.xml causes exclude() to be called on wrong object
In Jetty XML configuration, <Set name="hiddenClassMatcher"> evaluates its child elements in the scope of the parent WebAppContext object, then calls setHiddenClassMatcher(result). The nested <Call name="exclude"> therefore tries to call exclude() on the WebAppContext (which has no such method) rather than on the ClassMatcher object. This will fail at runtime, preventing the CDI/Weld integration from being correctly configured.
The fix is to use <Get> instead of <Set>, which retrieves the existing ClassMatcher via getHiddenClassMatcher() and makes it the target for the nested <Call name="exclude">.
| <Set name="hiddenClassMatcher"> | |
| <Call name="exclude"> | |
| <Arg> | |
| <Array type="java.lang.String"> | |
| <Item>org.eclipse.jetty.ee10.servlet.DecoratingListener</Item> | |
| </Array> | |
| </Arg> | |
| </Call> | |
| </Set> | |
| <Get name="hiddenClassMatcher"> | |
| <Call name="exclude"> | |
| <Arg> | |
| <Array type="java.lang.String"> | |
| <Item>org.eclipse.jetty.ee10.servlet.DecoratingListener</Item> | |
| </Array> | |
| </Arg> | |
| </Call> | |
| </Get> |
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Good catch — <Set> would call exclude() on the WebAppContext which doesn't have that method. Fixed in 343f882 by changing to <Get> so that the existing ClassMatcher is retrieved first and exclude() is called on it.
<Set> would call exclude() on the WebAppContext (which has no such method). <Get> retrieves the existing ClassMatcher and calls exclude() on it correctly. Co-Authored-By: Jerry Oliphant <jerry.oliphant@cognition.ai>
Summary
Full migration of the project from Java 8 / Java EE (javax namespace) to Java 21 / Jakarta EE 10 (jakarta namespace). This touches every layer: Maven compiler settings, dependencies, Jetty plugin, XML descriptors, and Java source imports.
Key changes:
maven.compiler.release=21javax.servlet-api:3.1.0→jakarta.servlet-api:6.0.0,cdi-api:1.2→jakarta.enterprise.cdi-api:4.0.1maven-war-plugin2.5 → 3.4.0,jetty-maven-plugin9.x →jetty-ee10-maven-plugin12.0.14,weld-servlet2.x →weld-servlet-shaded5.1.2.Finaljavax.servlet.*,javax.inject.*,javax.enterprise.*,javax.annotation.*imports →jakarta.*equivalents.javax.naming.*(JDK) correctly left unchanged.Build compiles cleanly with
mvn clean installunder JDK 21.Updates since last revision
jetty-context.xml: Changed<Set name="hiddenClassMatcher">to<Get name="hiddenClassMatcher">so thatexclude()is called on the existingClassMatcherobject rather than on theWebAppContext(which has noexclude()method). Caught by Devin Review.Review & Testing Checklist for Human
jetty-context.xmlJetty 12 classloader config — the old Jetty 9serverClassesnegative pattern was replaced with<Get name="hiddenClassMatcher"><Call name="exclude">forDecoratingListener. The<Set>→<Get>bug was fixed, but the overall approach (class name, exclude pattern) still needs runtime validation to confirm Weld integrates correctly with Jetty 12's classloading.contextXmlplacement inside<webApp>in the Jetty EE10 Maven plugin config — it was moved from a top-level plugin config element to nested under<webApp>. Confirm this matches the Jetty 12 EE10 plugin API.ManagerObjectFactoryclass name —jetty-env.xmlreferencesorg.jboss.weld.resources.ManagerObjectFactorywhich was correct for Weld 2.x. Confirm this factory class still exists in Weld 5.1.2.Final.mvn jetty:runinjetty-maven-cdi/and hithttp://localhost:8080/— compilation passed but CDI/Weld/Jetty runtime wiring was NOT tested. Verify the page renders "Hello web-overwrite.xml!" (confirming JNDI + CDI injection both work).BeanManager injection succeededandBeanManager JNDI lookup succeededduring Jetty startup — this confirms the JNDI binding injetty-env.xmlis wired correctly with the new Jakarta class references.Notes
javax.naming.*imports inDefaultGreeting.javaare intentionally unchanged — these are JDK classes, not Jakarta EE.javax.elexclusion oncdi-apiwas removed since the Jakarta CDI API no longer bundles it.beans.xmlis empty and was left unchanged (still valid for CDI discovery).Link to Devin session: https://app.devin.ai/sessions/f5b0f927228b4f749afaacbc48a1d173
Requested by: @jerryoliphant-cog