Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/index.xhtml Not Found in ExternalContext as a Resource

Tags:

jsf

jsf-2

My JSF web application shows the following error:

/index.xhtml Not Found in ExternalContext as a Resource.

My directory structure is:

- Java Resource
-- src
--- br.com.k19.controle
---- NumeroAleatorioBean.java
--- resources
- JavaScript Resources
- build
- WebContent
-- META-INF
-- Web Pages
--- index.xhtml
--- formulario.xhtml
-- Web-Inf

Where do I need to put my /index.xhtml in this structure?

like image 618
Rafael Souza Avatar asked Oct 31 '13 19:10

Rafael Souza


2 Answers

I faced this issue recently. I tried cleaning the Tomcat Work Directory, Clean, and Publish. After that, when I started the server, the application was running smooth.

For independent tomcat server, clean dir --> temp, work, and inside webApp directory, remove all the existing unarchived project. Restart the Tomcat, it worked for me.

like image 156
Sach.In Avatar answered Sep 19 '22 15:09

Sach.In


The WebContent folder represents the web content. You placed the index.xhtml file inside Web Pages subfolder so the right URL would be

http://localhost:8080/ProjectName/Web Pages/index.xhtml

and thus not

http://localhost:8080/ProjectName/index.xhtml

as you seemed to expect.

If you want to have it on the context root, just get rid of the Web Pages folder altogether and move those .xhtml files directly inside WebContent folder, in the same level as META-INF and WEB-INF:

ProjectName
 |-- Java Resources
 |    `-- src
 |         `-- br.com.k19.controle
 |              `-- NumeroAleatorioBean.java
 |-- resources
 |-- JavaScript Resources
 |-- build
 `-- WebContent
      |-- META-INF
      |-- WEB-INF
      |    |-- faces-config.xml
      |    `-- web.xml
      |-- index.xhtml
      `-- formulario.xhtml

Note: Java is case sensitive. Web-Inf is definitely not the same as WEB-INF. Be careful or you'll have a security hole.

like image 21
BalusC Avatar answered Sep 22 '22 15:09

BalusC