Hello World Example Fails to Run
LovingSalamander opened this issue · comments
Jetty version(s)
jetty-12
Jetty Environment
core?
Java version/vendor (use: java -version)
openjdk 22.0.1 2024-04-16
OpenJDK Runtime Environment Temurin-22.0.1+8 (build 22.0.1+8)
OpenJDK 64-Bit Server VM Temurin-22.0.1+8 (build 22.0.1+8, mixed mode)
OS type/version
macOS 14.4.1 (23E224)
Description
Following the steps of https://jetty.org/docs/jetty/12/programming-guide/maven-jetty/jetty-maven-helloworld.html#configuring-embedded-jetty-with-maven gives error:
[ERROR] Failed to execute goal on project hello-world: Could not resolve dependencies for project org.example:hello-world:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.eclipse.jetty:jetty-server:jar:12.0.10-SNAPSHOT (absent): Could not find artifact org.eclipse.jetty:jetty-server:jar:12.0.10-SNAPSHOT
I looked up the latest version of this artifact at https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server/12.0.10, so I tried using 12.0.10
instead of 12.0.10-SNAPSHOT
, and got a new error:
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[16,24] cannot find symbol
[ERROR] symbol: class HttpServletResponse
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[17,29] cannot find symbol
[ERROR] symbol: class ServletException
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[11,8] org.example.HelloWorld is not abstract and does not override abstract method handle(org.eclipse.jetty.server.Request,org.eclipse.jetty.server.Response,org.eclipse.jetty.util.Callback) in org.eclipse.jetty.server.Request.Handler
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[20,28] cannot find symbol
[ERROR] symbol: variable HttpServletResponse
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[21,20] cannot find symbol
[ERROR] symbol: method setHandled(boolean)
[ERROR] location: variable baseRequest of type org.eclipse.jetty.server.Request
How to reproduce?
Follow the steps of the tutorial
We need to get rid of the "-SNAPSHOT" portion of that example.
Use <jettyVersion>12.0.10</jettyVersion>
for now.
We need to get rid of the "-SNAPSHOT" portion of that example.
Use
<jettyVersion>12.0.10</jettyVersion>
for now.
When I use that version and run the example as-is, I get the following error:
[ERROR] symbol: class HttpServletRequest
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[16,24] cannot find symbol
[ERROR] symbol: class HttpServletResponse
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[17,29] cannot find symbol
[ERROR] symbol: class ServletException
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[11,8] org.example.HelloWorld is not abstract and does not override abstract method handle(org.eclipse.jetty.server.Request,org.eclipse.jetty.server.Response,org.eclipse.jetty.util.Callback) in org.eclipse.jetty.server.Request.Handler
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[20,28] cannot find symbol
[ERROR] symbol: variable HttpServletResponse
[ERROR] location: class org.example.HelloWorld
[ERROR] /Users/LovingSalamander/development/java/maven-jetty-example/src/main/java/org/example/HelloWorld.java:[21,20] cannot find symbol
[ERROR] symbol: method setHandled(boolean)
[ERROR] location: variable baseRequest of type org.eclipse.jetty.server.Request
@LovingSalamander oops, looks like that documentation has not been ported to jetty-12. A better guide is to look at the javadoc, particularly for eg the Request.Handler
which has a simple HelloWorld
example: https://javadoc.jetty.org/jetty-12/org/eclipse/jetty/server/Request.Handler.html