Skip to content

Adapt to jakarta.servlet* to prevent issues#418

Closed
kiril-keranov wants to merge 3 commits intoapache:masterfrom
kiril-keranov:javax_to_jakarta
Closed

Adapt to jakarta.servlet* to prevent issues#418
kiril-keranov wants to merge 3 commits intoapache:masterfrom
kiril-keranov:javax_to_jakarta

Conversation

@kiril-keranov
Copy link
Copy Markdown

@kiril-keranov kiril-keranov commented Apr 30, 2026

In newer versions of commons-logging the org.apache.commons.logging.impl.ServletContextCleaner is still javax.servlet* compatible. Versions 1.3.x though are widely used in Tomcat 10/ TomEE 10.1.x which are jakarta.servlet.* compatible, for example latest versions of TomEE 10.1.x plume include commons-logging 1.3.5 in the tomee/lib folder subject of the common classloader.
Thus if someone uses this ServletContextCleaner will result in

java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
		...
		at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
		at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
	Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContextListener
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1353)
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1165)
		... 51 more

The PR addresses this issue. Apart from adjusting org.apache.commons.logging.impl.ServletContextCleaner the japicmp-maven-plugin is tuned to exclude this class from the checks in order not to signal for incompatibility because of the javax->jakarta modification.
The existing BasicServletTestCase covers this so new test is not added.

The issue is described also in LOGGING-199

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute?
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@kiril-keranov kiril-keranov changed the title Adapt to jakarta.servlet* Adapt to jakarta.servlet* to prevent issues Apr 30, 2026
@garydgregory
Copy link
Copy Markdown
Member

How does this not blow up users on javax stacks?

@kiril-keranov
Copy link
Copy Markdown
Author

How does this not blow up users on javax stacks?

Its been a while, I guess users still on javax stack should put some migration efforts if they haven't already.

Comment thread pom.xml Outdated
<version>4.0.1</version>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not 6.1.0?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The issue was experienced in a Tomcat 10.1.x supporting 6.0.0, latest Tomcat 11 though is already on 6.1.0, will update it

@garydgregory
Copy link
Copy Markdown
Member

I'll create a PR that doesn't kneecap javax users... we'll see if it's any better.

@garydgregory
Copy link
Copy Markdown
Member

garydgregory commented Apr 30, 2026

@kiril-keranov

What do you think about PR #419, the servlet container config would need to be updated to point to the new class.

@kiril-keranov
Copy link
Copy Markdown
Author

@kiril-keranov

What do you think about PR #419, the servlet container config would need to be updated to point to the new class.

@garydgregory thanks for addressing this! Wrote some comments in #419

@garydgregory
Copy link
Copy Markdown
Member

Closing this PR in favor of PR #419. Thank you @kiril-keranov 🚀

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.

2 participants