Search code examples
google-app-enginejettyjava-11

App Engine Java 11 helloworld-servlet sample on a local jetty: 404 error after loading page


I am trying to run on a local server the sample published by google at this page: helloworld-servlet

There was no issue when I ran it a few weeks ago but now there is a 404 error after loading the (jsp) page.

As instructed in the Readme the steps to run on a local server are:

1 At \appengine-java11\appengine-simple-jetty-main run:
mvn install

2 At \appengine-java11\helloworld-servlet run:
mvn package

3 At \appengine-java11\appengine-simple-jetty-main run:

mvn exec:java -Dexec.args="../helloworld-servlet/target/helloworld.war"

4 visit: http://localhost:8080/hello

It loads the page (a jsp) with styled text but gives a 404 error in devtools: GET http://localhost:8080/favicon.ico 404 (Not Found)

I tried these but the issue persists:

1 mvn dependency:purge-local-repository

2 jar tf helloworld.war shows correct contents

3 Issue persists when sample is built & run on a different pc.

4 Upgrade of jetty to version 11 from 9 makes no difference.

JDK SE 17.0.10 is installed on both machines, previously might have been something different.


Solution

  • It loads the page (a jsp) with styled text but gives a 404 error in devtools: GET http://localhost:8080/favicon.ico 404 (Not Found)

    That's correct. You should see: enter image description here

    That's all it's supposed to do.

    If you're not seeing that, this was my setup:

    $ java -version
    openjdk version "17.0.9" 2023-10-17
    OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
    OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)
    
    $ mvn -version
    Apache Maven 3.9.6
    

    And my install steps:

    git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
    cd java-docs-samples\appengine-java11\appengine-simple-jetty-main
    mvn install
    cd ../helloworld-servlet
    mvn clean package
    cd ../appengine-simple-jetty-main
    mvn install
    mvn exec:java -Dexec.args="../helloworld-servlet/target/helloworld.war"
    

    Then navigate to: http://localhost:8080/hello

    PS: The page isn't a JSP, it's just a HttpServlet (HelloAppEngine.java)