Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Jakarta based application servers #1075

Merged
merged 1 commit into from
Jan 10, 2025
Merged

Conversation

tmortagne
Copy link
Member

@tmortagne tmortagne commented Sep 2, 2024

See xwiki/xwiki-rendering#318 for the rendering side of things.
See xwiki/xwiki-platform#3388 for the platform side of things.

Jira URLs

Changes

Description

The idea is to do just enough for XWiki to work in jakarta based Application servers (Jetty 11+, Tomcat 10+).

Important

This PR might look like a big change already but it's actually very far from a 100% jakarta XWiki. What was done is really just the strict minimum to work in a jakarta application server and there will still be a lot of work after that to fully migrate to jakarta.
See https://design.xwiki.org/xwiki/bin/view/Proposal/Jakartamigration for more details.

Jakarta WebSocket 2.1.1

XWiki has been migrated to WebSocket 2.1.1 without any kind of bridge, so every WebSocket related APIs are broken. There was no obvious way to keep supporting WebSocket 1 but fortunately no use of those APIs were found in contrib extensions.

Jakarta Validation 3.0.2

XWiki has been migrated to Validation 3.0.2 (and Hibernate Validator 8.0.1) without any kind of bridge. A Javax Validation API JAR remain in the XWiki WAR because it's referenced by Jersey, but XWiki itself only support Jakarta Validation. In practice, it just means that Javax Validation annotations used in a contrib extension are going to be ignored. It's easy for an extension to support both Javax and Jakarta XWiki versions by declaring both Java Javax and Jakarta Validation annotations.

Jakarta Servlet 5.0

Migration to jakarta

  • A javax.servlet <-> jakarta.servlet has been introduced.
  • No Servlet related API should be broken.
  • Except that the Filter and Servlet implementations declared in web.xml have all been moved to jakarta without keeping a javax compatible version. The reason is that there is no point keeping supporting those if XWiki is only used in jakarta based application servers, keeping the same class name also reduce the number of changes in the web.xml (in a sense, breaking them improve retro compatibility).
  • All the oldcore servlet related APIs are now deprecated
    • The most commons Servlet related API has been added to the Container API to reduce the need to directly access it
    • A new script oriented Container API has been introduced
  • Move to XJetty to Jetty 12 EE10 (instead of EE8)
  • XWiki is now doing its best by default (in Jetty and Tomcat only right now) to enable everything it can find to allow any character in URLs at init
  • New Tomcat 10 based Debian packages

Behavior changes

  • Redirect URLs are now checked in all contexts (injected by a servlet filter for all requests)
  • By default, relative redirect URLs are now resolved by XWiki instead of the application server (reduce setups requirement)

Jakarta Inject 2.0.1

It was probably not strictly required, but both javax and jakarta Inject APIs are now supported at the same time.

  • it did not made any sense for GenericProvider to be public, so I deprecated it and introduced two new internal tools (one for javax and the other for jakarta) to take care of the default Provider implementation/

TODO

  • run/fix Environment Tests
  • would be good to optimize a bit more the size of the xjetty package (i.e. add some more JAR exclusions)

Executed Tests

Not much new tests, but every single UI test and a lot of unit tests are impacted by this change so just the fact that they are passing is a good test. I also tried to migrate as little as possible from javax to jakarta as a way to test the bridges.

Expected merging strategy

  • Prefers squash: Yes

@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 6 times, most recently from 628ce76 to 1e396dd Compare September 9, 2024 08:06
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 4 times, most recently from 53e8776 to 6fa6229 Compare September 18, 2024 13:51
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 2 times, most recently from cc5d051 to 95d6762 Compare October 4, 2024 12:22
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 5 times, most recently from 663432b to 8dba7a2 Compare October 24, 2024 10:14
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 6 times, most recently from 0fa5c49 to 81cb0b0 Compare November 5, 2024 15:52
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 4 times, most recently from 688bdcc to 062a383 Compare November 21, 2024 08:41
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch from 062a383 to 8bdf6cd Compare November 21, 2024 15:56
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 2 times, most recently from b596e0b to f49be74 Compare November 28, 2024 15:41
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch from f49be74 to 16bf257 Compare December 6, 2024 17:32
@tmortagne tmortagne marked this pull request as ready for review December 26, 2024 08:41
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch from 16bf257 to 827adf2 Compare December 27, 2024 09:00
@manuelleduc
Copy link
Contributor

I also tried to migrate as little as possible from javax to jakarta as a way to test the bridges.

@tmortagne it this a temporary step to validate the bridge? i.e., do we want to move all javax to jakarta quickly?

@tmortagne
Copy link
Member Author

tmortagne commented Jan 8, 2025

@tmortagne it this a temporary step to validate the bridge? i.e., do we want to move all javax to jakarta quickly?

The way I see it, the idea would be to migrate existing code only after a few releases, and we are happy with how things are behaving. But new code should obviously try to use jakarta APIs as much as possible (I tried to provide jakarta versions of all the APIs and to deprecate javax based ones, at least for stuff which have been migrated already like servlet and inject).

Copy link
Contributor

@michitux michitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be subtle bugs in some of the adapters and converters. It would be great if we could have automated tests that protect against such bugs similar to the tests that I wrote for listeners, see, e.g., https://github.com/xwiki/xwiki-rendering/blob/9ac37383fe66215642ffc9f01e456c294a9f422f/xwiki-rendering-api/src/test/java/org/xwiki/rendering/listener/chaining/AbstractChainingListenerTest.java#L191. There also appear to be quite some TODOs left, do you plan to implement the missing parts or at least document clearly what is unsupported?

@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch 5 times, most recently from 4487179 to f989213 Compare January 9, 2025 07:31
XCOMMONS-2797: Allow accessing a javax.inject.Provider as a jakarta.inject.Provider and the opposite
XCOMMONS-2963: Upgrade to Servlet 5.0
XCOMMONS-2962: Provide a javax/jakarta bridge for Servlet APIs
XCOMMONS-2994: Upgrade to Websocket 2.1.1
XCOMMONS-2108: Upgrade to Bean Validation 3.0.2
XCOMMONS-2109: Upgrade to Hibernate Validator 8.0.1
XCOMMONS-2475: Use Expressly instead of Apache EL
@tmortagne tmortagne force-pushed the feature-deploy-jakarta branch from f989213 to 9879228 Compare January 10, 2025 12:45
@tmortagne tmortagne merged commit f85b3b6 into master Jan 10, 2025
@tmortagne tmortagne deleted the feature-deploy-jakarta branch January 10, 2025 13:00
tmortagne added a commit that referenced this pull request Jan 10, 2025
XCOMMONS-2797: Allow accessing a javax.inject.Provider as a jakarta.inject.Provider and the opposite
XCOMMONS-2963: Upgrade to Servlet 5.0
XCOMMONS-2962: Provide a javax/jakarta bridge for Servlet APIs
XCOMMONS-2994: Upgrade to Websocket 2.1.1
XCOMMONS-2108: Upgrade to Bean Validation 3.0.2
XCOMMONS-2109: Upgrade to Hibernate Validator 8.0.1
XCOMMONS-2475: Use Expressly instead of Apache EL

* change since place holders
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.

3 participants