Problema com JSF 2.0

3 respostas
B

Olá pessoal,

Eu estou tentando seguir um tutorial para aprender JSF 2.0 mas não está dando muito certo. Estou seguindo esse aqui:

Quando executo o projeto ocorre erro:

HTTP Status 500 - javax.servlet.ServletException: null source

type Exception report

message javax.servlet.ServletException: null source

description The server encountered an internal error (javax.servlet.ServletException: null source) that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: null source

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)

com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:359)

com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:150)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:96)

com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)

root cause

javax.servlet.ServletException: null source

javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)

org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)

org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)

org.apache.jsp.index_jsp._jspService(index_jsp.java:74)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)

com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:359)

com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:150)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:96)

com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)

root cause

java.lang.IllegalArgumentException: null source

java.util.EventObject.(EventObject.java:56)

javax.faces.event.SystemEvent.(SystemEvent.java:67)

javax.faces.event.ComponentSystemEvent.(ComponentSystemEvent.java:69)

javax.faces.event.PostRestoreStateEvent.(PostRestoreStateEvent.java:69)

com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256)

com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245)

com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)

com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)

com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)

org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:745)

org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:716)

org.apache.jsp.index_jsp._jspService(index_jsp.java:74)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)

javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:542)

com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:359)

com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:150)

com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:96)

com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)

com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)

javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)

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

Alguma idéia do que possa ser?

obrigado.

3 Respostas

B

Meus arquivos estão assim:

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
    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-app_2_5.xsd" >
    
    <welcome-file-list>
        <welcome-file>index.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>*.jsf</url-pattern>
    </servlet-mapping>
    
</web-app>
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_2_0.xsd"
	version="2.0">

</faces-config>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<!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="login.jsf"></jsp:forward>

</body>
</html>

Acho que deve ser alguma configuração errada em algum desses arquivos. Todos arquivos estão iguais aos do tutorial que postei no último post.

valeu!

A

Você criou a página login.xhtml que está nesse tutorial?
Se sim, tente alterar o atributo:

<welcome-file-list>  
    <welcome-file>index.jsp</welcome-file>  
</welcome-file-list>

para

login.jsf

no arquivo web.xml.

B

opa,

pessoal resolvido. Obrigado pela ajuda de quem postou.

nossa era uma coisa muito besta. Eu copiei e colei no Eclipse o código do arquivo login.xhtml que estava lá no tutorial. Acontece que lá o código do arquivo login.xhtml está junto com o código do arquivo home.xhtml. Quando copia e cola fica tudo em um arquivo só. Separei em 2 arquivos e funcionou.

Desculpem minha falta de atenção, realmente não tinha me atentado a isso e fiquei tentando consertar mexendo em outros arquivos.

abraço

Criado 29 de agosto de 2012
Ultima resposta 29 de ago. de 2012
Respostas 3
Participantes 2