Skip to content

feat(jakarta): Migrate remaining javax APIs to Jakarta namespace#2476

Open
jbonofre wants to merge 20 commits intoapache:mainfrom
jbonofre:feat/javax-to-jakarta-migration
Open

feat(jakarta): Migrate remaining javax APIs to Jakarta namespace#2476
jbonofre wants to merge 20 commits intoapache:mainfrom
jbonofre:feat/javax-to-jakarta-migration

Conversation

@jbonofre
Copy link
Member

Summary

  • Complete the javax to jakarta migration started with the Pax Web 11.0.1 upgrade (servlet APIs)
  • Migrate all remaining javax EE packages: annotation, inject, CDI, JAX-RS, JPA, JTA, interceptor, JMS, mail, and websocket
  • Update Java imports, POM dependencies, feature descriptors, Import-Package headers, and test resources across 60 files

Dependency changes

javax jakarta Version
javax.annotation:javax.annotation-api 1.3.2 jakarta.annotation:jakarta.annotation-api 2.1.1
javax.inject (geronimo-atinject) jakarta.inject:jakarta.inject-api 2.0.1
javax.enterprise:cdi-api 1.2 jakarta.enterprise:jakarta.enterprise.cdi-api 4.0.1
javax.ws.rs:javax.ws.rs-api 2.1.1 jakarta.ws.rs:jakarta.ws.rs-api 3.1.0
javax.persistence:javax.persistence-api 2.2 jakarta.persistence:jakarta.persistence-api 3.1.0
javax.transaction:javax.transaction-api 1.2 jakarta.transaction:jakarta.transaction-api 2.0.1
javax.interceptor:javax.interceptor-api 1.2.2 jakarta.interceptor:jakarta.interceptor-api 2.1.0
javax.jms:javax.jms-api 2.0.1 jakarta.jms:jakarta.jms-api 3.1.0
javax.mail:mail 1.4.7 com.sun.mail:jakarta.mail 1.6.7
javax.websocket:javax.websocket-api 1.1 jakarta.websocket:jakarta.websocket-api 2.1.1

Modules affected

  • Core: jms/, scheduler/, maven/core/, util/, bom/
  • Assemblies/Features: base, standard, enterprise, spring
  • Tooling: karaf-maven-plugin
  • Examples: REST, JPA, CDI, JMS, itest
  • Integration tests: itests/common, itests/test

Test plan

  • Verify the project compiles with mvn clean install -DskipTests
  • Run integration tests with mvn clean install on itests module
  • Verify enterprise features (JPA, JMS, transaction) install correctly in a Karaf instance
  • Verify example modules build and deploy correctly

Complete the javax to jakarta migration started with the Pax Web 11.0.1
upgrade (servlet APIs). This migrates all remaining javax EE packages:

- javax.annotation-api 1.3.2 -> jakarta.annotation-api 2.1.1
- javax.inject -> jakarta.inject-api 2.0.1
- javax.enterprise/cdi-api 1.2 -> jakarta.enterprise.cdi-api 4.0.1
- javax.ws.rs-api 2.1.1 -> jakarta.ws.rs-api 3.1.0
- javax.persistence-api 2.2 -> jakarta.persistence-api 3.1.0
- javax.transaction-api 1.2 -> jakarta.transaction-api 2.0.1
- javax.interceptor-api 1.2.2 -> jakarta.interceptor-api 2.1.0
- javax.jms-api 2.0.1 -> jakarta.jms-api 3.1.0
- javax.mail 1.4.7 -> com.sun.mail/jakarta.mail 1.6.7
- javax.websocket-api 1.1 -> jakarta.websocket-api 2.1.1

Updates Java imports, POM dependencies, feature descriptors,
Import-Package headers, and test resources across core modules,
examples, and integration tests.
@jbonofre jbonofre linked an issue Mar 23, 2026 that may be closed by this pull request
Maven 3.x provides javax.inject via Sisu/Plexus for plugin DI.
Migrating these to jakarta.inject breaks compilation since Maven 3
does not recognize Jakarta inject annotations.
The maven core bundle embeds javax.inject via shaded dependencies.
The Import-Package exclusion must remain !javax.inject* to prevent
an unresolvable OSGi requirement during feature verification.
…i feature

CDI 4.0.1 (Jakarta EE 10) introduces CDI Lite which requires
jakarta.enterprise.lang.model, unavailable in the feature resolution.
CDI 3.0.1 (Jakarta EE 9.1) provides the jakarta namespace without
the lang.model dependency.
Hibernate 5.x uses javax.persistence, incompatible with the Jakarta
migration. Hibernate 6.x uses jakarta.persistence natively.

- Update hibernate.version to 6.6.18.Final
- Change groupId from org.hibernate to org.hibernate.orm
- Remove hibernate-osgi bundle (dropped in 6.x, OSGi metadata now
  embedded in hibernate-core)
- Update hibernate-commons-annotations to 7.0.3.Final
@jbonofre
Copy link
Member Author

@fpapon I'm still working on it (updating Hibernate, etc) to have the services clean.

jbonofre and others added 13 commits March 23, 2026 18:04
…gi references

Hibernate 6 dropped the separate hibernate-osgi module as OSGi metadata
is now embedded directly in hibernate-core. Update the enterprise feature
to align with Hibernate 6.6.18 transitive dependencies:
- Replace org.hibernate:hibernate-osgi with org.hibernate.orm:hibernate-core in pom
- Switch from ANTLR 2 to ANTLR 4 runtime (antlr4-runtime 4.13.0)
- Remove javassist (no longer used by Hibernate 6)
- Update byte-buddy to 1.15.11 and jboss-logging to 3.5.0
- Replace org.jboss:jandex with io.smallrye:jandex 3.2.0
- Remove dom4j (no longer a Hibernate 6 dependency)
- Wrap hibernate-commons-annotations (broken OSGi metadata in 7.0.3)
- Update feature repo URLs from defunct hibernate-osgi to enterprise features
- Update JPA example hibernate version range from [5,6) to [6,7)
- Update transaction-api version range from [1.1,2) to [2.0,3) to match new 2.0.0 feature version
- Upgrade EclipseLink from 2.7.15 to 4.0.8 and remove obsolete antlr bundle
- Remove Aries JPA EclipseLink adapter (incompatible with EclipseLink 4.x)
- Upgrade Hibernate from 6.6.18 to 6.6.45.Final
- Update byte-buddy to 1.17.5 to match Hibernate 6.6.45 dependencies
- Use hibernate-commons-annotations 5.1.2.Final (proper OSGi manifest)
…ution

Hibernate ORM 6.6.45 has mandatory Import-Package on Jackson core,
databind, and dataformat-xml packages. Add jackson feature dependency
and jackson-dataformat-xml bundle (with woodstox transitive deps) to
the hibernate feature.

Exclude hibernate/hibernate-envers from feature verification as
Hibernate 6.6.x also has mandatory imports for vendor-specific
packages (com.ibm.websphere, oracle.jdbc, org.objectweb.jonas_tm,
org.postgresql.util, org.checkerframework) that cannot be provided
in a generic OSGi environment.
…PA 3.2

- Upgrade hibernate.version from 6.6.45.Final to 7.3.0.Final
- Upgrade Jakarta Persistence API from 3.1.0 to 3.2.0
- Upgrade Jakarta CDI API from 3.0.1 to 4.1.0 (required by Hibernate 7)
- Add jakarta.enterprise.lang-model 4.1.0 (new CDI 4.1 dependency)
- Upgrade Jakarta Interceptor API from 2.1.0 to 2.2.0 (required by CDI 4.1)
- Add JSON-B API 3.0.1, JSON-P API 2.1.3, Yasson 3.0.4, Parsson 1.1.7
- Remove hibernate-commons-annotations (merged into hibernate-core in Hibernate 7)
- Remove hibernate feature verification exclusion (no longer needed)
- Update JPA example hibernate version range from [6,7) to [7,8)
…0 OSGi resolution

Hibernate ORM 7.3.0.Final requires jakarta.validation [3.1.0, 4.0.0) as an
OSGi Import-Package. Add the bundle to the hibernate feature and bump the
version in hibernate-validator from 3.0.0 to 3.1.0.
….3.0

Add missing bundles and wrap overrides for Hibernate ORM 7.3.0.Final:
- jakarta.xml.bind-api 4.0.2 and jakarta.activation-api 2.1.3
- hibernate-models 1.1.0 (wrapped, new Hibernate 7.x dependency)
- Bump byte-buddy from 1.17.5 to 1.18.0
- Mark oracle.*, org.postgresql.*, tools.jackson.* as optional imports
…terceptor tests

The E2ETest uses jakarta.inject.Inject but the test dependency was still
the old geronimo-atinject_1.0_spec (javax.inject). Replace with
jakarta.inject-api 2.0.1.
Remove dependency on org.apache.aries.jpa.api (which pulls in
javax.persistence transitively) and use direct EntityManagerFactory
injection via OSGi DS @reference instead of JpaTemplate.
Replace all remaining geronimo-atinject_1.0_spec (javax.inject)
references with jakarta.inject-api 2.0.1 in itests/common, BOM, and
karaf-itest-example.
Upgrade CXF to 4.1.2 (Jakarta EE compatible), add jakarta.activation-api,
and update Jackson provider to jakarta.rs variant.
…a dependencies

Migrate CXF client from javax to Jakarta namespace by upgrading
cxf-rt-rs-client from 3.6.10 to 4.1.2, switching to
jackson-jakarta-rs-json-provider, and adding jakarta.activation-api.
…tibility

Pax Exam's injection framework requires javax.inject, not jakarta.inject.
The OSGi resolver cannot find the jakarta.inject package in the Pax Exam
test environment, causing itest failures.
…bility

Pax Exam injects test dependencies using javax.inject, not jakarta.inject.
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Test Results

237 files  ±0  237 suites  ±0   23m 11s ⏱️ +28s
923 tests ±0  872 ✅  - 3  48 💤 ±0  0 ❌ ±0  3 🔥 +3 
927 runs  ±0  876 ✅  - 3  48 💤 ±0  0 ❌ ±0  3 🔥 +3 

For more details on these errors, see this check.

Results for commit 5ee999e. ± Comparison against base commit e02d549.

This pull request removes 3 and adds 3 tests. Note that renamed tests count towards both.
org.apache.karaf.itests.JtaTest ‑ jakartaTransaction1_3AndDBCP2
org.apache.karaf.itests.JtaTest ‑ javaxTransaction1_2
org.apache.karaf.itests.JtaTest ‑ javaxTransaction1_2AndDBCP2
org.apache.karaf.itests.JtaTest ‑ jakartaTransaction2_0
org.apache.karaf.itests.JtaTest ‑ jakartaTransaction2_0AndDBCP2
org.apache.karaf.itests.JtaTest ‑ jakartaTransaction2_0_1AndDBCP2

♻️ This comment has been updated with latest results.

DBCP2 2.8.0 imports javax.transaction (not jakarta.transaction), so it
cannot resolve when the transaction-api feature provides
jakarta.transaction-api/2.0.1. Update tests to assert resolution failure
and align dependency versions with the current transaction-api feature.
Pax-JMS 1.1.3 still registers javax.jms.ConnectionFactory services.
The Karaf JMS module was migrated to jakarta.jms.ConnectionFactory,
causing a namespace mismatch where connection factories could not be
discovered. Revert until pax-jms supports the Jakarta namespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate to Jakarta namespace

2 participants