Programo há 32 anos, mas iniciante em Java, portanto, quem votar negativo, gentileza comenta o motivo... O que pode ser óbvio para você, pode ser inalcançável para outros.
Comecei um projeto Web com maven + JPA/Hibernate + JSF + primefaces.
Ao abrir (tomcat) o arquivo index.xhtml (localhost:8080/new-hibernate-primefaces/index.xhtml), aparecem os labels criados, todos em uma única linha, fora de formatação..
Nem mesmo um hello world funciona (hello.xhtml, quando chamo por hello.jsf)
Ao abrir (tomcat) o arquivo index.JSF (localhost:8080/new-hibernate-primefaces/index.jsf), ocorre o erro abaixo:
TENTATIVAS:
Já tentei várias sugestões daqui (pt) e do stackoverflow.com, mas nenhuma das propostas funcionou. Também já marquei as opções em properties: "Botão direito no projeto", propriedades, Project Facets --> runtimes: marcar: Apache Tomcat v9.0 e DESMARCAR JRE.
Já excluí e reconfigurei o Tomcat
Marcar Dynamic Web Modulo 3.0
Selecionar Java, JavaScript, JavaServer Faces 2.2, JPA
Também já fiz um novo projeto do zero e o erro persiste.
Um detalhe importante é que, na época, quando instalei o Eclipse, não havia marcado a opção "Desenvolvimento Web". Mas agora, adicionei os pacotes WebTools (acho que é isso).
-Localização dos arquivos: /new-hibernate-primefaces/WebContent/index.xhtml /new-hibernate-primefaces/WebContent/WEB-INF/faces-config.xml /new-hibernate-primefaces/WebContent/WEB-INF/web.xml /new-hibernate-primefaces/pom.xml /new-hibernate-primefaces/src/main/java/META-INF/persistence.xml
VERSÕES: Apache Tomcat: 9.0 Eclipse Version: 2020-09 (4.17.0) JDK 11.0.8 (NÃO foi marcada no projeto, conforme recomendação do professor)
Segue conteúdo dos principais arquivos:
INDEX.XHTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="ident" Value="Id" />
<h:inputText id="ident" readonly="true" value="#{usuarioPessoaManagedBean.usuarioPessoa.id}" />
<h:outputLabel for="nome" Value="Nome" />
<h:inputText id="nome" value="#{usuarioPessoaManagedBean.usuarioPessoa.nome}" />
<h:outputLabel for="sobrenome" Value="Sobrenome" />
<h:inputText id="sobrenome" value="#{usuarioPessoaManagedBean.usuarioPessoa.sobrenome}" />
<h:outputLabel for="email" Value="Email" />
<h:inputText id="email" value="#{usuarioPessoaManagedBean.usuarioPessoa.email}" />
<h:outputLabel for="login" Value="Login" />
<h:inputText id="login" value="#{usuarioPessoaManagedBean.usuarioPessoa.login}" />
<h:outputLabel for="senha" Value="Senha" />
<h:inputSecret id="senha" value="#{usuarioPessoaManagedBean.usuarioPessoa.senha}" />
<h:outputLabel for="idade" Value="Idade" />
<h:inputText id="idade" value="#{usuarioPessoaManagedBean.usuarioPessoa.idade}" />
</h:panelGrid>
</h:form>
</h:body>
</html>
WEB.XML:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>new-hibernate-primefaces</display-name>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<session-config>
<session-timeout>5</session-timeout>
</session-config>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
</web-app>
FACES-CONFIG.XML:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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_3.xsd"
version="2.3">
</faces-config>
POM.XML:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>new-hibernate-primefaces</groupId>
<artifactId>new-hibernate-primefaces</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>new-hibernate-primefaces</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax.faces/jsf-api -->
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.20</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.faces/jsf-impl -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.20</version> <!-- Corrigido -->
</dependency>
<!-- https://mvnrepository.com/artifact/org.primefaces/primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.22.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.4.22.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
IMAGENS QUE PODEM SER ÚTEIS:
Obrigado!