[#2198 Jakarta support
This is an attempt to automatically generate alternative modules using the new jakarta packages instead of javax ones
The approach uses Eclipse Transformer, which transforms Java binaries and can correctly map packages, type names, and related resource names.
There are four modules affected: axon-messaging, axon-modelling, axon-eventsourcing and axon-configuration. For each, there is now a respective module with the -jakarta suffix.
The following applies for all of the new modules:
- Dependencies
- at module creation time, the original dependencies were manually copied from the respective POM to the new one. Thus those need to be manually synchronized if the original ones change in the future.
- explicit
javaxdependencies were replaced by respectivejakartaones - original dependencies that transitively depended on
javaxwere either updated to newer (jakartacompatible) versions or replaced with respective alternatives
- Source code
- there is no source code in the new modules
- compiled classes (both
main/javaandtest/java) are copied from the respective original module withmaven-dependency-plugin. For this to work, the original modules need to generatetest-jars - copied classes are transformed in place by the
transformer-maven-plugin - transformed tests are executed by the
maven-surefire-plugin, which allows testing the code after transformation
- Tests
- the vast majority of tests pass after those changes
- the failing tests are currently excluded in the POM.
- some tests rely on Spring and need to be changed as Spring does not yet support
jakartapackages - I tested the new modules with a demo I use for presentations, and it worked fine (the demo does not use JPA, though)
Considering the above, this PR is a work in progress. There are more things to do, such as:
- investigate test failures and provide fixes
- introduce respective integration tests
- test the new modules with a fairly complex sample app that is not based on Spring (I couldn't find one)
This pull request will resolve #2198.
Interesting! It finds a "bug" in axon-integrationtests-jakarta but not in axon-integrationtests module, which uses the same code. I guess SonarCloud is configured to ignore it in the original module. Anyways, I updated the dependency to ojdbc8, which is in Maven Central. Tests pass locally in both modules, and we can get rid of the local jar.
Hi @smcvb
I think this is as far as I can go with this PR. I'll mark it as ready for review now. I believe it'll be ready to merge once we rewrite the tests to not use Spring.
Summary of the changes
- [x] added new
axon-messaging-jakarta,axon-modelling-jakarta,axon-eventsourcing-jakarta,axon-configuration-jakarta, andaxon-integrationtests-jakartamodules. - [x] made
AbstractResourceInjectorrecognizejakarta.inject.Inject - [x] changed
hibernate-entitymanagertohibernate-corebecause it has ajakartacounterpart - [x] configured
axon-messaging,axon-modelling,axon-eventsourcing,axon-configuration, andaxon-integrationtestsmodules, to build and publish respectivetest-jarartifacts. - [x] replaced
@Injectwith@Autowiredin some Spring-based tests because Spring does not recognize@Injectfromjakartapackage - [x] added the Jakarta related dependencies in
<dependencyManagent>. - [x] created
jakarta.*.legacy.versionproperties and added explicit dependencies on old versions inaxon-eventsourcing,axon-configuration,axon-integrationtests,axon-spring, andaxon-spring-boot-autoconfiguremodules, because Spring (and some other) depend on old jakarta jars (those havingjavaxpackage) - [x] removed local
ojdbc7.jarand configuredaxon-integrationteststo useojdbc8from Maven - [x] bumped the version of
hibernate-validatorto7.0.4.Final(which is Jakarta namespace aware) in all*-jakartamodules
Failing tests
Currently, Spring-based, JPA tests in *-jakarta modules fail with
Caused by: java.lang.TypeNotPresentException: Type javax.persistence.EntityManagerFactory not present
Some of those seem complex, testing multiple threads/transactions scenarios. I'm afraid I don't have enough expertise in the area to properly change those to not use Spring. However, @Morlack offered to do it. I'll leave it between the two of you to decide how to proceed.
For convenience, here is the list of failing tests (currently excluded in the respective POMs) :







