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

2.x/examples/osgi-helloworld-webapp does not work with Jetty 12 but with Jetty 10 #5522

Open
gpfeifer opened this issue Jan 30, 2024 · 12 comments

Comments

@gpfeifer
Copy link

gpfeifer commented Jan 30, 2024

Background

I'm trying to migrate some legacy code from Jetty 10 to Jetty 12.
I'm using Jetty 12 ee8 and Jersey 2.x.

Issue

https://github.com/eclipse-ee4j/jersey/tree/2.x/examples/osgi-helloworld-webapp does work with Jetty 10 but not with Jetty 12.

See jetty/jetty.project#11315

[2024-01-30 13:07:02] [WARNING] [org.eclipse.jetty.ee8.webapp.WebAppContext] Failed startup of context oeje8w.WebAppContext@65099eb1{/helloworld,/helloworld,file:///tmp/jetty-0_0_0_0-8080-bundleFile-_helloworld-any-3729372861759542448/webapp/,false}{file:/home/gpf/cix/git/vpms-server/vsrv-deliver/server/vpms-server-data/org.eclipse.osgi/98/0/bundleFile}
[2024-01-30 13:07:02] [INFO ] [org.eclipse.jetty.server.handler.ContextHandler] Started oeje8n.ContextHandler$CoreContextHandler@13f204a3{/helloworld,/helloworld,b=file:///tmp/jetty-0_0_0_0-8080-bundleFile-_helloworld-any-3729372861759542448/webapp/,a=UNAVAILABLE,h=oeje8n.ContextHandler$CoreContextHandler$CoreToNestedHandler@705b8920{STARTED}}

Jersey throws a ResourceFinderException with this message:

org.glassfish.jersey.server.internal.scanning.ResourceFinderException: The URI scheme bundleentry of the URI bundleentry://[...] not supported. Package scanning deployment is not supported for such URIs.
Try using a different deployment mechanism such as explicitly declaring root resource and provider classes using an extension of javax.ws.rs.core.Application

@jansupol
Copy link
Contributor

Jetty 12 is aligned with Jakarta EE 10, whereas Jetty 9 is aligned with Jakarta EE 8.
Jersey 3.1.x is aligned with Jakarta EE 10, whereas Jersey 2.x is aligned with Jakarta EE 8.
Hence, Jersey 2.x supports Jetty 9, Jersey 3.0.x Jetty 11, and Jersey 3.1.5+ Jetty 12.

@gpfeifer
Copy link
Author

IMPORTANT: You need to add this to MANIFEST

  Jetty-Environment: ee8

@gpfeifer
Copy link
Author

@jansupol We wrote a comment at the same time :-)

I'm using Jetty 12 with EE8

@jansupol
Copy link
Contributor

@gpfeifer Can you point us to a documentation regarding this MANIFEST tag?

@gpfeifer
Copy link
Author

gpfeifer commented Jan 30, 2024

There is no documentation as far as I know. As I wrote in jetty/jetty.project#11315 it took me some hours to find out that this entry is needed. I found this entry in: https://github.com/jetty/jetty.project/tree/jetty-12.0.x/jetty-ee8/jetty-ee8-osgi

@gpfeifer
Copy link
Author

I created a PR (#5524). The PR contains a minimalistic example of a working osgi-helloworld-jetty-12-webapp. Unfortunately a automated JUnit test is missing.

@joakime
Copy link
Member

joakime commented Jan 31, 2024

Jetty 12 is aligned with Jakarta EE 10, whereas Jetty 9 is aligned with Jakarta EE 8.
Jersey 3.1.x is aligned with Jakarta EE 10, whereas Jersey 2.x is aligned with Jakarta EE 8.
Hence, Jersey 2.x supports Jetty 9, Jersey 3.0.x Jetty 11, and Jersey 3.1.5+ Jetty 12.

This is the chart you need ...

Jetty version Environment EE Level Servlet ver Servlet namespace
12 ee10 Jakarta EE10 Servlet 6.0 jakarta.servlet
12 ee9 Jakarta EE9 Servlet 5.0 jakarta.servlet
12 ee8 Jakarta EE8 Servlet 4.0 javax.servlet
11 n/a Jakarta EE9 Servlet 5.0 jakarta.servlet
10 n/a Jakarta EE8 Servlet 4.0 javax.servlet
9 n/a Java EE7 Servlet 3.1 javax.servlet

Note: Jetty 12 server has no servlet dependencies anymore.
The various environments in Jetty 12 have the servlet layers (along with other APIs that are also in that EE level)
When EE11 releases, it'll still be Jetty 12, but just a new environment definition called "ee11".

@joakime
Copy link
Member

joakime commented Jan 31, 2024

Using your definitions of Jersey versions to EE levels, the extended chart would look like ...

Jetty version Environment EE Level Servlet ver Servlet namespace Jersey Version
12 ee10 Jakarta EE10 Servlet 6.0 jakarta.servlet Jersey 3.1.5+
12 ee9 Jakarta EE9 Servlet 5.0 jakarta.servlet Jersey 3.0.x
12 ee8 Jakarta EE8 Servlet 4.0 javax.servlet Jersey 2.x
11 n/a Jakarta EE9 Servlet 5.0 jakarta.servlet Jersey 3.0.x
10 n/a Jakarta EE8 Servlet 4.0 javax.servlet Jersey 2.x
9 n/a Java EE7 Servlet 3.1 javax.servlet Not supported

But that doesn't make sense, as we know you support Jetty 9.

Looking at your codebase.

Ah, Jersey 2.x codebase doesn't support EE8, it supports EE7 (based on it's use of Servlet 2.4/2.5), that's the mistake!
The corrected chart would be ...

Jetty version Environment EE Level Servlet ver Servlet namespace Jersey Version
12 ee10 Jakarta EE10 Servlet 6.0 jakarta.servlet Jersey 3.1.x+
12 ee9 Jakarta EE9 Servlet 5.0 jakarta.servlet Jersey 3.0.x
12 ee8 Jakarta EE8 Servlet 4.0 javax.servlet Not supported
11 n/a Jakarta EE9 Servlet 5.0 jakarta.servlet Jersey 3.0.x
10 n/a Jakarta EE8 Servlet 4.0 javax.servlet Not supported
9 n/a Java EE7 Servlet 3.1 javax.servlet Jersey 2.x

@joakime
Copy link
Member

joakime commented Jan 31, 2024

Technically speaking, Jersey 2.x supports Eclipse Jetty 7, as that's the version that introduced support for Servlet 2.4 (Jetty 8 was Servlet 3.0)

@gpfeifer
Copy link
Author

gpfeifer commented Feb 1, 2024

@joakime The codebase I'm working on is running in production and is using Jetty 10 and Jersey 2.x. I'm migrating this codebase to Jetty 12. The Jersey example (2.x/examples/osgi-helloworld-webapp) works with Jetty 10 and Jersey 2.x. But is does not work with Jetty 12 ee8. My example (osgi-helloworld-webapp-jetty-12) works with Jetty 12 (ee8) and Jersey 2.x. I will use the approach used in osgi-helloworld-webapp-jetty-12 in my codebase. Is there anything against it?

@gpfeifer
Copy link
Author

gpfeifer commented Feb 1, 2024

@joakime Or in other words: I don't get it.

Jetty 10 works with Jersey 2.x in production.
Why is Jetty 10 not supported by Jetty 2.x?

Jetty 12 e88 seems to work with Jetty 2.x, but I'm not finished with my migration.
Why is Jetty 12 e88 not supported by Jetty 2.x?

@joakime
Copy link
Member

joakime commented Feb 1, 2024

@gpfeifer some history ...

  • Servlet 1.0 thru Servlet 3.1 were backward compatible. (meaning if you wrote for and older version and deployed on a newer version, no big deal, it'll work)
  • Servlet 4.0 added a few things to the APIs, but isn't 100% backward compatible with Servlet 3.1 or older (mostly due to behavior changes).
  • Servlet 5.0 is not backward compatible with any versions before it (due to namespace changes)
  • Servlet 6.0 removed classes and methods, changed important APIs, and changed behaviors. (this means if you wrote for Servlet 5.0 and deployed here, you'll likely have issues)
  • Servlet 6.1 has a few changes to support new browser changes. (going from 6.0 to 6.1 should be trivial)

The fact that it seems to work for you is just luck, and is not to be relied on, as the most trivial change can suddenly cause issues for you. (eg: using Java 11 or older then moving to Java 17 and using those old versions of the Servlet spec, suddenly some of your responses are different.)
Jersey has newer versions to support (some of) the servlet specs listed above, in turn those containers (like Jetty) support the improvements in the Servlet spec too.

In Jetty 12, ee8, we try to maintain bug for bug compatibility with how things worked back then, but it's not perfect, and only strives for the bugs that existed back in EE8 days, not earlier.
Some things we cannot work around, like the changes in the JVM impacting behavior of your webapp.

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

No branches or pull requests

3 participants