0

I am trying to create a simple primefaces app (name pf2) with Primefaces 11, JDK 17, Tomcat 10.1.7, maven 3.8.8. Its war file was deployed in Tomcat with no errors However, when I tried to access http://localhost:8080/pf2/, it displayed http status 404, not found. No error in a log file/console. I searched the primefaces sample with this stack Primefaces 11, JDK 17, Tomcat 10.1.7, but many of them were old version jdk 8, tomcat 9. Bellow are my files in the simple app. Thanks

pom.xml

web.xml


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Hello, World!</title>
</h:head>
<h:body>
    <h:form>
        <p:outputLabel value="test" />
        This is a test
    </h:form>
</h:body>
</html>


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    
    <display-name>My PrimeFaces Application</display-name>
    
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>ui-lightness</param-value>
    </context-param>
    
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>jakarta.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>
    
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
    
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>pf2</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>pf2</name>
  <description>test for primefaces</description>
  
    <dependencies>
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-api</artifactId>
            <version>10.0.0</version>
            <scope>provided</scope>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>11.0.0</version>
            <classifier>jakarta</classifier>
        </dependency>
        
        <!-- add any other dependencies your project needs here -->
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <!-- add any other plugins your project needs here -->
        </plugins>
    </build>
  
</project>


seenukarthi
  • 8,241
  • 10
  • 47
  • 68
dev
  • 11
  • 1
  • 3
  • Please don't add code as images – Jasper de Vries Apr 17 '23 at 16:40
  • @Jasper de Vries, I tried to add code as code block when I tried to post. However, stackoverflow didn't let me to post since the post was identified as spam. I searched and found a suggestion of using images. Then I was able to post. I will try to edit and post code again to see if it lets me. – dev Apr 17 '23 at 17:06
  • Tomcat is not a Jakarta EE server and therefore having `jakarta.jakartaee-api` as `provided` is wrong. You need to manually install Jakarta Faces which is one of PrimeFaces requirements. Head to the section "Installing Faces on Tomcat 10 or newer" of the answer to the abovelinked duplicate. Or, simply use a normal Jakarta EE server such as TomEE, WildFly, GlassFish, etc. – BalusC Apr 17 '23 at 17:35
  • @BalusC Thank you for your prompt help. I tried Tomcat and added 2 dependencies org.apache.myfaces.cores and jakarta.servlet.jsp.jstl as your ref link. And I didn't get http status 404 anymore. Though now I got status 500 with No Factories configured for this Application, listener, I think this is something else with web.xml. I will need to search for this separate issue. Thanks again for guiding me to a right direction. – dev Apr 17 '23 at 20:35

0 Answers0