Search code examples
javajetty

org.eclipse.jetty.server.handler.ScopedHandler is missing


I`m using oracle openJDK 20 with maven.

<properties>
        <maven.compiler.source>20</maven.compiler.source>
        <maven.compiler.target>20</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

<dependencies>
<dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>12.0.3</version>
</dependency>
<dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>11.0.18</version>
</dependency>
<dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
</dependency>

And i cant use org.eclipse.jetty.servlet.ServletHandler, becouse this class exetends org.eclipse.jetty.server.handler.ScopedHandler, but it is missing

I tried to search this problem and found nothing.


Solution

  • Do not mix versions of Jetty.

    All of your Jetty artifacts should be on the same version of Jetty.

    Also, you should read the documentation on Jetty 12 (pay attention to "environments")

    The artifact jetty-servlet does not exist in Jetty 12, as Jetty 12 is based on environments (with support for multiple environments at the same time in different webapps).

    You have to decide which environment you want to use and then use the appropriate maven coordinates.

    Example: you seem to want to use Servlet 6.0, that would belong to the environment labeled ee10, so use those artifacts.