Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Question about ALPN when embedding Jetty inside an OSGi bundle

Your specific ALPN proposal would be a partial solution if it were possible.
There would need to be either a code change in Jetty, or totally custom code on your end, to allow manually declaring ALPNProcessors.
That would just get you to the next ServiceLoader that is required.

A quick scan of Jetty 12, there are 106 usages of java.util.ServiceLoader across Jetty itself and there are countless more in the third party dependencies too.
58 of those hits are specific to Jetty OSGI bundles.

Note that OSGi has formal declarations for java.util.ServiceLoader behaviors.
Our Jetty bundles declare the limited scope of the ServiceLoader, using osgi behaviors.

Example:
Require-Capability: osgi.extender;filter:="(osgi.extender=osgi.servicelo
 ader.processor)";resolution:=optional,osgi.serviceloader;filter:="(osgi
 .serviceloader=org.eclipse.jetty.io.ssl.ALPNProcessor$Client)";resoluti
 on:=optional;cardinality:=multiple,osgi.ee;filter:="(&(osgi.ee=JavaSE)(
 version=17))"

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Thu, Jan 11, 2024 at 11:52 AM Silvio Bierman <sbierman@xxxxxxxxxxxxxxxxxx> wrote:
Thank you Joakim,

I looked into SpiFly and it seems quite complex. It sounds to me like it is targeted at crossing bundle boundaries through ServiceLoaders while all I want is for Jetty (which is an internal implementation detail of my bundle) to use its own ALPN implemenation. Nothing ServiceLoader, ALPN or even Jetty/Servlet should be visible outside the bundle. I am not doing HTTP whiteboard at the OSGI level and do not want to deploy Jetty as OSGI bundle(s). If I could hardwire my embedded Jetty to its ALPNProvider and forsake ServiceLoader altogether that would be my prefered solution. Is that in any way possible?

Cheers, Silvio


On 30-12-2023 01:59, Joakim Erdfelt wrote:
For OSGi you must (as in not optional) include a java ServiceLoader provider for your OSGi environment.

The most common is Apache SpiFly.

This is the most common reason for various things in Jetty not working in OSGi. (typically it's one of the following the ALPNProcessors, WebSocket, Precomputed Headers Impls, WebApp Configurations)

Joakim Erdfelt / joakim@xxxxxxxxxxx


On Fri, Dec 29, 2023 at 11:46 AM Silvio Bierman via jetty-users <jetty-users@xxxxxxxxxxx> wrote:
I have Jetty 12.0.5 embedded inside an OSGi bundle with all dependencies
embedded. Jetty starts normally and I can get it working with a HTTP
listener. But when I add the code to add HTTPS support I get an error at
startup:

java.lang.IllegalStateException: No Server ALPNProcessors!

The jetty-alpn-server and jetty-alpn-java-server artifacts are included
in the bundle JAR as embedded dependency but the ALPN processor still
can not be found, probably because the OSGi class loader is incompatible
with how the search for ALPN processors works.

Does anyone know how I can resolve this?

Cheers,

Silvio

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users


Back to the top