OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.14k stars 587 forks source link

Error 404: jakarta.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /index.jsf #27496

Open urbandroid opened 7 months ago

urbandroid commented 7 months ago

This setup works for both payara and wildfly but it fails for openliberty

https://github.com/urbandroid/graphql-jakarta/tree/debug

it throws error below when i try to open http://localhost:9080/deneme2-web/:

Error 404: jakarta.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /index.jsf

I'm using openliberty/open-liberty:full-java11-openj9-ubi docker image here is my server.xml

`<?xml version="1.0" encoding="UTF-8"?>

jakartaee-10.0 `
pnicolucci commented 7 months ago

@urbandroid , We have not tested your application yet but looking at the name of repo and your server.xml are you expecting the jakartaee-10.0 feature to enable GraphQL? If you're project requires GraphQL see: https://openliberty.io/docs/latest/reference/feature/mpGraphQL-2.0.html

urbandroid commented 7 months ago

@pnicolucci Graphql works no problem there, i'm trying to create a app server agnostic jakarta ee starter. so no I'm not expecting jakarta ee feature to enable GraphQL. Basic Jakarta ee feature which is JSF not working as expected for Openliberty.

volosied commented 6 months ago

Hi @urbandroid

Sorry for following up a week late...

I'm unable to you your app locally on my machine. If you could provide logs (or the built app), that would be great.

Add the following to the server.xml:

<logging  traceSpecification="com.ibm.ws.jsf*=all:org.apache.myfaces*=all:com.ibm.ws.webcontainer*=all:com.ibm.ws.jsp=all"
traceFileName="trace.log"
maxFileSize="20"
maxFiles="10"
traceFormat="BASIC" />

You'll find the trace under the <server>/logs folder. Thanks!

urbandroid commented 6 months ago

@volosied On debug branch

  1. mvn clean install
  2. docker build -f openliberty/Dockerfile -t urbandroid/deneme2 .
  3. docker run -it --name openliberty -p 9080:9080 urbandroid/deneme2
  4. open http://localhost:9080/deneme2-web/
volosied commented 6 months ago

Hmm. I get a Context Root Not Found when I go to http://localhost:9080/deneme2-web/

If I use curl from within the container, the page is accessed (but this error):

      <h2>Members</h2>Error 500: jakarta.servlet.ServletException: WELD-000049: Unable to invoke public void deneme2.deneme2.data.MemberListProducer.retrieveAllMembersOrderedByName&#40;&#41; on deneme2.deneme2.data.MemberListProducer@bd18ae1a

Once thing I noticed -- you appears to be missing the faces servlet mapping in the web.xml.

https://github.com/urbandroid/graphql-jakarta/blob/debug/deneme2-web/src/main/webapp/WEB-INF/web.xml

You'll need this:

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

This mapping might be the problem, actually. You list index.jsf here: https://github.com/urbandroid/graphql-jakarta/blob/debug/deneme2-web/src/main/webapp/index.html#L21

But that mapping doesn't exist.

Give it a try and let me know if it works. I tested with the ear locally (without docker) and it seemed to have worked ( but I still encountered the CDI exception)

urbandroid commented 6 months ago

adding servlet mapping solved the issue but i'm not sure that should be needed Wildfly and Payara works fine without it, what does the jakarta spec says about it. Is it needed according to standarts?

volosied commented 6 months ago

Liberty uses MyFaces. However those two servers use Mojarra, so the mapping may likely be added automatically based on various conditions.

https://jakarta.ee/specifications/faces/4.0/jakarta-faces-4.0#a6076

Jakarta Faces implementations must support web application that define a <servlet-mapping> that maps any valid url-pattern to the FacesServlet. 
In addition to FacesServlet, Jakarta Faces implementations may support other ways to invoke the Jakarta Faces request processing lifecycle, but applications that rely on these mechanisms will not be portable.

I would recommend to contain faces servlet mappings so that the applications are portable.

volosied commented 6 months ago

Quick follow up.

@pnicolucci noticed that Mojarra looks for the FacesConfig annotation (which you have here), but MyFaces does not. This likely explains why Faces Servlet is not added automatically.

I saw comments in Mojarra regarding FacesConfig and CDI, so let me start a new discussion what the proper handing is here. We may be able to update MyFaces.