I am following this tutorial: https://openliberty.io/guides/microprofile-config-intro.html
I have the following servlet :
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet(urlPatterns="/car-types")
public class InventoryServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
System.out.println("Inside the /cat-types servlet preparing to respond with carInventory.html");
RequestDispatcher view = request.getRequestDispatcher("carInventory.html");
view.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
My webapp folder contains inside the file carInventory.html, however when I access in the browser the link I get the following message: RESTEASY003210: Could not find resource for full path: http://localhost:9080/OpenLibertyExperiments/carInventory.html
The system.out message from the doGet message is seen in the server logs, so the servlet is reached corectly, but the html file is not found...this is what I understand from the error.
This is what features i defined to use:
<featureManager>
<feature>servlet-5.0</feature>
<feature>restfulWS-3.0</feature>
<feature>jsonp-2.0</feature>
<feature>jsonb-2.0</feature>
<feature>cdi-3.0</feature>
<feature>mpConfig-3.0</feature>
<feature>mpRestClient-3.0</feature>
<feature>mpOpenAPI-3.0</feature>
</featureManager>
Any ideas on what could it be ?
So I tried Scott's idea, and commented out all @ApplicationPath annotations that I had in my codebase, with the exception of 1, which was needed, because the js part of the example needed to access an endpoint for data. After doing these changes all seems to be ok.
Bottom line is be careful not to have more than 1 @ApplicationPath in your codebase when using servlets ?