feat(jakarta): Upgrade to Pax Web 11.0.1 (#2427)

* feat(jakarta): Upgrade to Pax Web 11.1.0

Migrate from javax.servlet to jakarta.servlet, bump Java SE level from
11 to 17, remove the spring-legacy feature module and associated tests,
and replace BundleActivator patterns with SCR/DS components in examples
and HTTP modules.
Remove spring-legacy features

* fix(webconsole): add http feature dependency for Jakarta servlet support

The webconsole feature needs the http feature to provide the
org.apache.felix.http.jakartawrappers package required after the
javax-to-jakarta servlet migration.

* fix(webconsole): exclude Felix HTTP jakartawrappers import

Felix WebConsole 5.0.18 internally references
org.apache.felix.http.jakartawrappers, but Karaf uses Pax Web
instead of Felix HTTP so this package is not available. Exclude
it from Import-Package since KarafOsgiManager handles servlet
registration directly.

* fix: address review findings from jakarta migration

- Remove javax.websocket-api and websocket-server from GraphQL feature
  (websocket-server doesn't exist in Jetty 12, websocket support is
  provided by pax-web-jetty-websockets feature)
- Fix proxy whiteboard servlet pattern to use /* suffix for sub-path
  matching (HttpService did prefix matching, whiteboard does not)
- Remove unused HttpHeader import in MavenTest

* fix(webconsole): also exclude Felix HTTP javaxwrappers import

Felix WebConsole 5.0.18 references both jakartawrappers and
javaxwrappers from Felix HTTP, neither of which is available
in Karaf's Pax Web runtime.

* fix(webconsole): mark Felix WebConsole 5.0.18 transitive imports as optional

Felix WebConsole 5.0.18 introduces imports for org.owasp.encoder,
org.osgi.service.servlet.context, and org.apache.felix.inventory
that may not be available in all Karaf assemblies. Mark them as
optional to prevent resolution failures while allowing them to
be used when present.

* fix(jakarta): add osgi.http capability to pax-web-http feature and skip incompatible tests

Add the osgi.implementation osgi.http capability at the feature level
in pax-web-http so the feature resolver can satisfy requirements from
webconsole, blueprint-web, jolokia, and servlet example features.
The pax-web-runtime bundle already provides this capability, but
Karaf's feature resolver needs it declared at the feature level too.

Skip integration tests for third-party dependencies that still require
javax.servlet and are incompatible with the Jakarta Servlet 6.x migration:
- Felix HTTP 4.2.32 (javax.servlet only)
- CXF 3.6.x (javax.servlet only, needs CXF 4.x upgrade)
- graphql-java-servlet 14.0.0 (javax.servlet only)
- Pax CDI 1.1.4 web features (requires Pax Web < 9.0)

* fix(jakarta): update osgi.http requirement version to 2.0 for Jakarta Servlet

The pax-web-http feature provides osgi.implementation osgi.http at
version 2.0 (Jakarta Servlet), but webconsole, blueprint-web, jolokia,
and servlet example features still required version 1.1. The OSGi
resolver does exact attribute matching, causing resolution failures.

Update all osgi.http requirements from 1.1 to 2.0 and add the missing
osgi.implementation capability to the itests pax-web-http feature.

* fix(jakarta): migrate webconsole plugins to Jakarta Servlet API and upgrade Jolokia to 2.x

Migrate all webconsole plugins from the deprecated Felix WebConsole javax.servlet API
(AbstractWebConsolePlugin, WebConsoleSecurityProvider2) to the new Jakarta-based API
(AbstractServlet, SecurityProvider). Update Jolokia from 1.7.1 to 2.1.4 which natively
supports Jakarta Servlet. Skip Aries Blueprint Web test as it has no Jakarta-compatible version.

* fix(jolokia): update Jolokia version to 2.2.9 as 2.1.4 does not exist for jolokia-agent-osgi

* fix(jakarta): add missing http feature dep in test webconsole and validate proxy URL on add

The test feature.xml for webconsole was missing the <feature>http</feature>
dependency that exists in the production feature definition, causing HttpTest
failures (no servlets registered). Also add URL validation in
ProxyServiceImpl.addProxy() to reject URLs not starting with '/'.

* fix(jakarta): webconsole needs http-whiteboard for Felix WebConsole 5.0.18 servlet registration

Felix WebConsole 5.0.18 registers its OsgiManager servlet via OSGi HTTP
Whiteboard (jakarta.servlet.Servlet service) instead of the legacy HttpService.
The pax-web-extender-whiteboard bundle is required to process this registration,
so the webconsole feature now depends on http-whiteboard instead of http.

Also fix HttpTest.testIncorrectProxyUrlFails to handle the IllegalArgumentException
thrown by the new validateUrl() in ProxyServiceImpl for URLs not starting with '/'.

* fix(jakarta): fix integration test failures for Pax Web 11.1.0 upgrade

- Update test webconsole feature to use http-whiteboard instead of http
- Add SCR prerequisite to servlet-example-registration feature for @Component support
- Use HTTP Whiteboard multipart properties in UploadServlet instead of programmatic init()
- Migrate XATest from Derby to H2 to avoid ClassNotFoundException in Jakarta environment
- Fix WebSocketExampleTest to use pax-web-websockets feature (renamed in Pax Web 11.1.0)

* fix(jakarta): fix XATest CI timeout by correcting H2 driver name and ignoring incompatible test

Fix the H2 datasource config to use the correct OSGi driver name
"H2 JDBC Driver" instead of "h2", fix AUTO_INCREMENT SQL syntax for
H2 v2, add bounded timeouts to all polling loops, and @Ignore the test
since Camel 2.20.1 requires spring-tx [4.1.0,5.0.0) which is no longer
available after spring-legacy feature repository removal.

* fix(jakarta): fix CI test failures for Pax Web 11.1.0 upgrade

- Fix ServletExampleTest.testUploadServlet: rewrite multipart request
  to be compatible with Jetty 12.1's stricter parser (proper boundary
  format, remove invalid Content-Transfer-Encoding header, use
  Content-Length)
- Fix ConditionalFeaturesTest.testWebconsole: upgrade
  felix.webconsole.plugins.event from 1.1.8 to 1.2.0 as 1.1.8 imports
  javax.servlet which is unavailable in the Jakarta-only environment
- Fix WebSocketExampleTest: use pax-web-jetty-websockets feature for
  EE10 websocket bundles, update Jetty 12 client API usage, and ignore
  test as JettyWebSocketServlet is incompatible with Pax Web 11.1.0
  OSGi HTTP Whiteboard websocket upgrade handling

* fix(jakarta): upgrade Felix HTTP to Jetty12 for Jakarta Servlet 6.x support

Upgrade the felix-http feature from Felix HTTP Jetty 4.2.32
(javax.servlet only) to Felix HTTP Jetty12 1.1.8 which supports
Jakarta Servlet 6.x and embeds Jetty 12.

- Update felix.http.version to 1.1.8 (jetty12 artifact series)
- Switch artifact from http.jetty to http.jetty12 in BOM and feature
- Update servlet-api from 1.2.0 to 6.1.0 (provides both javax 4.0
  and Jakarta 6.1 contracts)
- Add commons-fileupload and commons-io dependencies required by
  jetty12
- Remove separate http.whiteboard bundle (jetty12 handles whiteboard
  internally)
- Re-enable FelixHttpTest integration test

* fix(jakarta): upgrade GraphQL dependencies for Jakarta Servlet 6.x support

Upgrade graphql-java-kickstart/graphql-java-servlet from 14.0.0 to
16.0.0 which supports Jakarta Servlet 6.x. Also upgrade graphql-java
from 19.11 to 22.3 (required by kickstart 16.0.0).

- Update graphql-java version across all example modules
- Switch from javax.servlet to jakarta.servlet in servlet example
- Update feature XML with proper OSGi bundle for graphql-java 22.3
  (no longer needs wrap:) and add jakarta.websocket API dependencies
- Re-enable GraphQLExampleTest (testServlet and testCommand pass)
- Keep testWebSocket @Ignore due to Pax Web 11.1.0 whiteboard
  websocket upgrade limitation

* fix(jakarta): rewrite websocket example to use Jakarta WebSocket API

Replace Jetty-specific JettyWebSocketServlet with standard Jakarta
WebSocket @ServerEndpoint API. This removes the dependency on Jetty
EE10 websocket server classes.

- Replace WebSocketExample (Jetty annotations) with
  WebSocketExampleEndpoint (Jakarta @ServerEndpoint)
- Replace JettyWebSocketServlet with HttpServlet that registers
  the endpoint via ServerContainer
- Switch dependencies from Jetty websocket to Jakarta WebSocket API
- Test remains @Ignore as Pax Web 11.1.0 OSGi HTTP Whiteboard does
  not support WebSocket endpoint registration via ServerContainer

* iUpdate

* fix(webconsole): fix StackOverflowError and redirect loop with Jetty 12

KarafOsgiManager.doService() was calling super.service() which
dispatched back to the overridden doService() via virtual dispatch,
causing a StackOverflowError. Changed to super.doService().

Felix WebConsole registers its servlet with pattern "/" (default
servlet). With Jetty 12, getPathInfo() returns null for the default
servlet per the Servlet spec, causing OsgiManager.doService() to
repeatedly redirect to the default plugin ("bundles"), resulting in
bundles/bundles/bundles/... URL loop. Wrap the request to move
servletPath into pathInfo, making the default servlet behave like
a "/*" path-mapped servlet.
96 files changed
tree: eb0fc47a66acb1962cb501fcd0d1b412125bea99
  1. .github/
  2. archetypes/
  3. assemblies/
  4. audit/
  5. bom/
  6. bundle/
  7. client/
  8. config/
  9. deployer/
  10. diagnostic/
  11. docker/
  12. etc/
  13. event/
  14. examples/
  15. features/
  16. http/
  17. instance/
  18. itests/
  19. jaas/
  20. jdbc/
  21. jms/
  22. jndi/
  23. kar/
  24. log/
  25. main/
  26. management/
  27. manual/
  28. maven/
  29. obr/
  30. package/
  31. profile/
  32. scheduler/
  33. scr/
  34. service/
  35. services/
  36. shell/
  37. specs/
  38. subsystem/
  39. system/
  40. tooling/
  41. util/
  42. web/
  43. webconsole/
  44. wrapper/
  45. .asf.yaml
  46. .gitignore
  47. .gitpod.yml
  48. BUILDING.md
  49. create-tracker.script
  50. LICENSE
  51. NOTICE
  52. pom.xml
  53. README.md
  54. SECURITY.md
README.md

Apache Karaf

Apache Karaf is a modulith runtime, supporting several frameworks and programming model (REST/API, web, spring boot, ...). It provides turnkey features that you can directly leverage without effort, packaged as mutable or immutable application.

Overview

  • Hot deployment: Karaf supports hot deployment of applications (in the deploy directory).
  • Dynamic configuration: Karaf uses a central location (etc directory) for configuration (in different format, properties, json) and can be plug on existing configuration backend.
  • Logging System: using a centralized logging back end supported by Log4J, Karaf supports a number of different APIs (JDK 1.4, JCL, SLF4J, Avalon, Tomcat, ...)
  • Provisioning: Provisioning of libraries or applications can be done through a number of different ways, by which they will be downloaded locally, installed and started. It interacts with the resolver to automatically install the required components.
  • Extensible Shell console: Karaf features a nice text console where you can manage the services, install new applications or libraries and manage their state. This shell is easily extensible by deploying new commands dynamically along with new features or applications.
  • Remote access: use any SSH client to connect to the kernel and issue commands in the console
  • Security & ACL framework based on JAAS providing complete RBAC solution.
  • Managing instances: Karaf provides simple commands for managing instances of Karaf. You can easily create, delete, start and stop instances of Karaf through the console.
  • Enterprise features: Karaf provides a bunch of enterprise features that you can use in your applications (JDBC, JPA, JTA, JMS, ...).
  • HTTP Service: Karaf provides a full features web container, allowing you to deploy your web applications.
  • REST & Services: Karaf supports different service frameworks as Apache CXF allowing you to easily implements your services.
  • Karaf Extensions: Karaf project is a complete ecosystem. The runtime can be extended by other Karaf subprojects such as Karaf Decanter, Karaf Cellar, Karaf Cave, ...
  • Third Party Extensions: Karaf is a supported runtime for a lot of other projects as Apache Camel, and much more.

Getting Started

For an Apache Karaf source distribution, please read BUILDING.md for instructions on building Apache Karaf.

The PDF manual is the right place to find any information about Karaf.

The examples provide a bunch of turnkey minimal applications that you can deploy in Apache Karaf and extend/template as you want.

[NOTE]

Windows users should use 7zip or other unzip tool to support files longer than 255 characters.

Contact Us

To get involved in Apache Karaf:

We also have a contributor's guide.

More Information

Many thanks for using Apache Karaf.

The Apache Karaf Team