0

I just started learning JSF. I downloaded-installed maven 3.6, apache tomcat, apache tomee webprofile, apache tomee plume glassfish; and followed some tutorials for creating a web app using jsf and completely lost.

Finally i could make a jsf web app work but now the main page shows 404 error.If i add index.xhtml manually at the end of url, it shows the content.

My last working projects details are below:

faces-config.xml:

faces-config.xml file

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
    http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

</faces-config>

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">
  <servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
  </servlet>

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

  <display-name>Archetype Created Web Application</display-name>
</web-app>

I added only this block to pom.xml after i create a maven webapp project:

<dependency>
  <groupId>org.glassfish</groupId>
  <artifactId>javax.faces</artifactId>
  <version>2.4.0</version>
</dependency>

My question is, what am i doing wrong and default page shows 404?

Ali
  • 69
  • 1
  • 1
  • 12
  • jsf (mojarra) is not an official release. 2.3.x use the latest. but can you get plain html page to work – Kukeltje Mar 17 '19 at 16:14
  • well, i did get it to work but is it normal that i have to add /index.xhtml at the end of url, manually? – Ali Mar 17 '19 at 19:06
  • If you don't have a welcome fike configured it is (and this is all not jsf related) – Kukeltje Mar 17 '19 at 19:51
  • https://stackoverflow.com/questions/27562813/set-default-home-page-via-welcome-file-in-jsf-project – Kukeltje Mar 17 '19 at 19:59

0 Answers0