Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: /login.xhtml Not Found in ExternalContext as a Resource

I'm using JBoss 7.1 with JSF 2.1/Prime Faces and keep running into the error listed in the title. I've tried many of the suggestions made here and all end up with the same error.

File structure is:

WEB-INF
   faces
      login.xhtml

I have the following in web.xml:

<display-name>clientAccountManager</display-name>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
    <param-value>true</param-value>
</context-param>

I am accessing the file currently using the following URL:

http://localhost:8080/clientAccountManager/faces/login.xhtml

I have also changed the URL pattern to *.xhtml and used:

http://localhost:8080/clientAccountManager/login.xhtml

with the same result.

What am I missing?

like image 444
Chris K. Avatar asked Oct 30 '12 22:10

Chris K.


1 Answers

You made 2 mistakes.

  1. /WEB-INF folder is for configuration files, include files, template files, tag files, etc, which are supposed to be hidden from direct access, not for publicly accessible files. Put publicly accessible files outside /WEB-INF folder.

  2. /faces folder should not be used at all. A virtual /faces/* URL pattern on FacesServlet doesn't imply that you should have a physical folder like that. Remove it.

So, all with all, just

WebContent
 |-- META-INF
 |-- WEB-INF
 |    |-- faces-config.xml
 |    `-- web.xml
 `-- login.xhtml

and

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

and

http://localhost:8080/clientAccountManager/login.xhtml

should do.

See also:

  • Which XHTML files do I need to put in /WEB-INF and which not?
like image 104
BalusC Avatar answered Nov 11 '22 02:11

BalusC