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

Cannot start Jetty 11 websocket server on OSGi #11089

Closed
freyssin opened this issue Dec 20, 2023 · 3 comments
Closed

Cannot start Jetty 11 websocket server on OSGi #11089

freyssin opened this issue Dec 20, 2023 · 3 comments
Labels
Bug For general bugs on Jetty side

Comments

@freyssin
Copy link

Jetty version(s)
Jetty 11.0.18

Java version/vendor (use: java -version)
JDK 11.0.20.1

OS type/version
Windows 10

Description
We are trying to migrate our websocket services from Jetty 9.4.x to 11.0.x, we encounter 2 OSGi issues.

We have been using OSGi and Felix in the OW2/Joram project for many years. We have a working setup with Felix (7.0.5), Jetty 9.4, Felix Http and Jetty websocket bundles. Recently we upgraded our libraries to JEE 10: Jetty 11.0.18, Jersey 3.1.3, Felix Http (5.1.6). Our Rest services work correctly on this new platform, unfortunately we cannot find a working configuration for our websockets server.

We found a minimum configuration with the following bundles:

file:./bundle/slf4j-api.jar
file:./bundle/slf4j-jdk14.jar
file:./bundle/jetty-xml.jar
file:./bundle/jetty-webapp.jar
file:./bundle/websocket-jetty-api.jar
file:./bundle/websocket-jetty-common.jar
file:./bundle/websocket-core-common.jar
file:./bundle/websocket-servlet-11.0.18.jar
file:./bundle/websocket-core-server-11.0.18.jar
file:./bundle/websocket-jetty-server.jar
file:./bundle/org.apache.felix.http.servlet-api.jar
file:./bundle/org.apache.felix.log.jar
file:./bundle/org.apache.felix.http.jetty.jar

But during startup we have the following errors:

ERROR: Bundle org.eclipse.jetty.webapp [4] Error starting file:./bundle/jetty-webapp.jar (org.osgi.framework.BundleException: Unable to resolve org.eclipse.jetty.webapp [4](R 4.0): missing requirement [org.eclipse.jetty.webapp [4](R 4.0)] osgi.extender; (osgi.extender=osgi.serviceloader.processor) Unresolved requirements: [[org.eclipse.jetty.webapp [4](R 4.0)] osgi.extender; (osgi.extender=osgi.serviceloader.processor)])

ERROR: Bundle org.eclipse.jetty.websocket.common [6] Error starting file:./bundle/websocket-jetty-common.jar (org.osgi.framework.BundleException: Unable to resolve org.eclipse.jetty.websocket.common [6](R 6.0): missing requirement [org.eclipse.jetty.websocket.common [6](R 6.0)] osgi.extender; (osgi.extender=osgi.serviceloader.registrar) Unresolved requirements: [[org.eclipse.jetty.websocket.common [6](R 6.0)] osgi.extender; (osgi.extender=osgi.serviceloader.registrar)])

The 2 errors above seem to be due to OSGi extensions requested by the "org.eclipse.jetty.webapp" and "org.eclipse.jetty.websocket.common" bundles. I searched in the Jetty code and these annotations appeared from version 10:

Is this behavior correct? If so, what should I do to get around it? What would then be the correct OSGi configuration to start a Jetty websocket server with OSGi and more especially Felix?

PS: This problem may also be related to #6418.

@freyssin freyssin added the Bug For general bugs on Jetty side label Dec 20, 2023
@freyssin
Copy link
Author

There is a similar issue with the websocket client bundle:

ERROR: Bundle org.eclipse.jetty.websocket.client [28] Error starting file:./bundle/websocket-jetty-client.jar (org.osgi.framework.BundleException: Unable to resolve org.eclipse.jetty.websocket.client [28](R 28.0): missing requirement [org.eclipse.jetty.websocket.client [28](R 28.0)] osgi.extender; (osgi.extender=osgi.serviceloader.registrar) Unresolved requirements: [[org.eclipse.jetty.websocket.client [28](R 28.0)] osgi.extender; (osgi.extender=osgi.serviceloader.registrar)])

@freyssin
Copy link
Author

After adding an implementation of osgi.serviceloader.registrar/osgi.serviceloader.extender (spifly) all bundles are now correctly loaded.

However, I did an experiment by manually editing the manifests of the erroring bundles (*1) to remove the Require-Capability line and it seems to work. Would it be possible to generate these bundles without this mandatory dependency on spifly (or equivalent)?

(*1) jetty-webapp.jar, websocket-jetty-common.jar and websocket-jetty-client.jar.

@joakime
Copy link
Contributor

joakime commented Dec 21, 2023

The Require-Capability is a requirement to allow java.util.ServiceLoader to work.
Removing support for java.util.ServiceLoader is not a valid setup for Jetty.

Jetty 9 had few usages of java.util.ServiceLoader, but the upgrade to Jakarta EE 9 / Jetty 11, means that java.util.ServiceLoader is now a mandatory requirement for things to function properly across many things within Jetty itself, and it's various dependencies.

@freyssin freyssin closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

2 participants