AxonFramework icon indicating copy to clipboard operation
AxonFramework copied to clipboard

[#2198 Jakarta support

Open azzazzel opened this issue 4 years ago • 4 comments

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 javax dependencies were replaced by respective jakarta ones
    • original dependencies that transitively depended on javax were either updated to newer (jakarta compatible) versions or replaced with respective alternatives
  • Source code
    • there is no source code in the new modules
    • compiled classes (both main/java and test/java) are copied from the respective original module with maven-dependency-plugin. For this to work, the original modules need to generate test-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 jakarta packages
    • 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.

azzazzel avatar Jul 22 '22 19:07 azzazzel

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 22 '22 19:07 CLAassistant

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.

azzazzel avatar Jul 26 '22 07:07 azzazzel

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, and axon-integrationtests-jakarta modules.
  • [x] made AbstractResourceInjector recognize jakarta.inject.Inject
  • [x] changed hibernate-entitymanager to hibernate-core because it has a jakarta counterpart
  • [x] configured axon-messaging, axon-modelling, axon-eventsourcing, axon-configuration, and axon-integrationtests modules, to build and publish respective test-jar artifacts.
  • [x] replaced @Inject with @Autowired in some Spring-based tests because Spring does not recognize @Inject from jakarta package
  • [x] added the Jakarta related dependencies in <dependencyManagent>.
  • [x] created jakarta.*.legacy.version properties and added explicit dependencies on old versions in axon-eventsourcing, axon-configuration, axon-integrationtests, axon-spring, and axon-spring-boot-autoconfigure modules, because Spring (and some other) depend on old jakarta jars (those having javax package)
  • [x] removed local ojdbc7.jar and configured axon-integrationtests to use ojdbc8 from Maven
  • [x] bumped the version of hibernate-validator to 7.0.4.Final (which is Jakarta namespace aware) in all *-jakarta modules

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) :

axon-messaging-jakarta

axon-modelling-jakarta

axon-eventsourcing-jakarta

axon-integrationtests-jakarta

azzazzel avatar Jul 27 '22 10:07 azzazzel