Erro ao exibir um jsf?

13 respostas
J

Olá amigos estou iniciando o estudo para web e de inicio tô tendo uma dificuldade de exibir uma pagina com o texto “alô mundo” alguem teria uma dica de onde posso estar errando?
o servidor tomcat tá instalado e configurado.

Meu arquivo web.xml

<?xml version="1.0" encoding="ASCII"?>
<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_3_0.xsd" 
	version="3.0">
  <display-name>FinanceiroWeb</display-name>
  <servlet>
  	<display-name>Faces Servlet</display-name>
    <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>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
  	<param-name>javax.faces.PROJECT_STAGE</param-name>
  	<param-value>Development</param-value>
  </context-param>
  <welcome-file-list>
  	<welcome-file>index.html</welcome-file>
  	<welcome-file>index.htm</welcome-file>
  	<welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

meu arquivo alomundo.xhtml

<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Teste inicial JSF</title>
</h:head>
<h:body>
	<h:outputText value="Olá Mundo"/>
</h:body>
</html>

Mensagem de erro:

HTTP Status 404 - Servlet Faces Servlet is not available

type Status report

message Servlet Faces Servlet is not available

description The requested resource (Servlet Faces Servlet is not available) is not available.
Apache Tomcat/7.0.6

já fiz e refiz os passos mais não vejo onde estar o erro!

13 Respostas

R

No seu index.jsp faça isso:

&lt;jsp:forward page="/aloMundo.jsf"&gt;&lt;/jsp:

E no web.xml coloque isso:

&gt;&lt;context-param&gt;
		&lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;/param-name&gt;
		&lt;param-value&gt;.xhtml&lt;/param-value&gt;
	&lt;/context-param&gt;
desk
Olá, tente mudar ali no "cabeçalho" do seu web.xml a versão, ponha tudo 2.5 ou 3.0:
# <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"   
#     version="2.5">
e mude também:
# <servlet-mapping>  
#     <servlet-name>Faces Servlet</servlet-name>  
#     <url-pattern>*.xhtml</url-pattern>  
#   </servlet-mapping>
J

Amigo desculpe mais estou iniciando agora e não sei exatamente no index onde colocar a linha que você falou?

R

No index.jsp deixe apenas a linha q eu passei

J

Oi é o seguinte no meu projeto só existe esse dois arquivos que eu postei acima não existe a pagina index.jsp… tem o web.xml e tem o arquivo que eu quero exibir olamundo.xhtml. por isso não tô sabendo onde postar o que você falou, e com relação a versão no arquivo web.xml não fez diferença nenhum também.

R

Crie o index.jsp e coloque a linha

J

ok… criei o arquivo:

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="/alomundo.jsf"></jsp> 
</body>
</html>

mensagem de exibição:
HTTP Status 404 - Servlet Faces Servlet is not available

type Status report

message Servlet Faces Servlet is not available

description The requested resource (Servlet Faces Servlet is not available) is not available.
Apache Tomcat/7.0.6

R

Quais libs vc colocou no classpath?

J

as libs foram:

  • commons-beanutils-1.8.3
  • commons-collections-3.2.1
  • commons-digester-2.1
  • commons-logging-1.1.1
  • jstl-1.2
  • jstl-api-1.2
  • jstl-impl-1.2
R

tá faltando o .jar do Facelets

J

baixei e importei a versão: jsf-facelets-1.1.9.jar … continua com a mesma mensagem anterior!

J

Pessoal esse primeiro projeto que estou tendo contato, esta sendo tirado do Livro “Programação de Java para Web” de Décio Heinzelmann e Alexandre Altair da Novatec Editora já refiz todos os passos e não obtive sucesso no avanço do mesmo.

K

Boa tarde Joule e pessoal!

Eu também estou tentando fazer esse primeiro exemplo de jsf, mas aqui não da erro, e sim não aparece nada.

Na linha <h:outputText value=“Teste”/> não mostra nada. Mas quando se tira o h:outputText e só deixa o escrito, ai sim é exibido.

O que poderia ser?

Obrigado

Criado 2 de fevereiro de 2011
Ultima resposta 24 de fev. de 2011
Respostas 13
Participantes 4