Hello World com JSF [Problema] [RESOLVIDO]

7 respostas
J

Olá, estou tendo problemas em dar um simples Hello World com JSF, quando rodo com o Tomcat me vem o seguinte erro:

HTTP Status 500 - Servlet.init() for servlet Faces Servlet threw exception

--------------------------------------------------------------------------------

type Exception report

message Servlet.init() for servlet Faces Servlet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception 

javax.servlet.ServletException: Servlet.init() for servlet Faces Servlet threw exception
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	java.lang.Thread.run(Unknown Source)


root cause 

java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
	javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:812)
	javax.faces.FactoryFinder.getFactory(FactoryFinder.java:248)
	javax.faces.webapp.FacesServlet.init(FacesServlet.java:169)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	java.lang.Thread.run(Unknown Source)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.36 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.36

O que pode estar acontecendo? Agradeço desde já, obrigado :)

7 Respostas

J

Posta teu código johan
não conseguir identificar com os erros

J

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

</body>
</html>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">

</faces-config>

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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>World</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</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>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
</web-app>
J

O erro dá quando abro a página http://localhost:8080/World/index.faces

(World é o nome que dei ao projeto)

Hierarquia:

J

<url-pattern>/faces/*</url-pattern> <url-pattern>*.faces</url-pattern>
Modifica para

<url-pattern>*.jsf</url-pattern>

e acessa la http://localhost:8080/World/index.jsf

e outra percebir pela a foto que o seu arquivo .jsp está dentro da pasta WEB INF, sendo que é pra está dentro de WEBCONTENT

J

você tem que adicionar as lib para o projeto

jsf-api.jar
jsf-impl.jar

depois de adicionar
botão direito em cima > build path > add build path

J

Era exatamente isso! Muito obrigado cara!! :slight_smile:

J

edita teu tópico e coloca como resolvido.

Criado 16 de fevereiro de 2013
Ultima resposta 16 de fev. de 2013
Respostas 7
Participantes 2