jetty / jetty.project

Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
https://eclipse.dev/jetty
Other
3.86k stars 1.91k forks source link

Replace jetty.servlet.api with jakarta.servlet #9238

Closed PavelTurk closed 1 year ago

PavelTurk commented 1 year ago

Jetty uses jetty.servlet.api (https://github.com/eclipse/jetty.toolchain/blob/master/jetty-jakarta-servlet-api/pom.xml). This jar contains API for jakarta.servlet.

The problem appears when jetty is used in JPMS. If jetty is used with any application/library that needs jakarta.servlet in its module-info then it simply won't work, because jetty.servlet.api has same packages as jakarta.servlet. The only solution is to separate jetty and application/library to different JPMS layers, but it is not always a good solution.

Is there any way to replace jetty.servlet.api with jakarta.servlet?

joakime commented 1 year ago

Is there any way to replace jetty.servlet.api with jakarta.servlet?

Yes, starting with Servlet 6.0 and Jetty 12.

Prior to Servlet 6, the JAR is missing various things (schemas) and also doesn't have a valid JPMS setup.

joakime commented 1 year ago

Another way to look at it.

The Servlet 4.x and 5.x Spec/API jars are designed for use in projects that want to make webapps. It does not contain what's necessary for a Server implementation to function.

This was fixed with Servlet 6.x, now that Spec/API jar can fit both for the folks building webapps, AND folks building Server implementations.

PavelTurk commented 1 year ago

@joakime Thank you for detailed answer. Could you say when jetty 12 will be approximately released?

joakime commented 1 year ago

@PavelTurkish we have alpha release of Jetty 12 out now.

We'll have our first beta out in the next few weeks.

PavelTurk commented 1 year ago

@joakime I've started using Jetty 12 and came across with unusual (for me) maven dependency structure. I mean all these ee9, ee10 for some files. So, my dependency config looks like this:

<module groupId="org.eclipse.jetty.ee10" artifactId="jetty-ee10-servlet" version="12.0.0.alpha3"/>
<module groupId="org.eclipse.jetty.ee10" artifactId="jetty-ee10-servlets" version="12.0.0.alpha3"/>
<module groupId="org.eclipse.jetty" artifactId="jetty-util" version="12.0.0.alpha3"/>
<module groupId="org.eclipse.jetty.ee10" artifactId="jetty-ee10-webapp" version="12.0.0.alpha3"/>
<module groupId="org.eclipse.jetty" artifactId="jetty-xml" version="12.0.0.alpha3"/>
        ....

Is this jakarta standard? Or I do something wrong. I doubt because as I know maven classifiers are used for such scope. For example:

<module groupId="org.openjfx" artifactId="javafx-base" classifier="linux" version="19-ea+3" />

Could you explain the reason of such structure or I misunderstand something?

joakime commented 1 year ago

Jetty 12 supports ee8 / ee9 / ee10 at the same time, in different environments.

You can choose to only use ee10 if you want, and we expect that to be quite a common use case.

The artifacts you are referencing is for ee10 (which has Servlet 6, among other things). We chose not to use classifiers to isolate these deps, as they can be quite different, with different dependencies. A classified artifact is usually an optional attached artifact that belongs to the main artifact (eg: pom with jar), these classified artifacts don't have different dependencies from the main artifact.

PavelTurk commented 1 year ago

@joakime Thank you very much for your answer and help.