Duvidas JSF

4 respostas
A

e ai rapaziada blz… esto começando a trabalhar com jsf mas ja de inicio achei muitos problemas… eu uso o netBeans 5.5 e quando mando executar o sistema da um monte de erro e cai numa tela com erro “http status 500” e não tenho ideia do q seja… meu jsp index

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!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>Exemplo JSF</title>
    </head>
    <body>
        <f:view>
            <h:form>
                <center>
                    <h1>Agenda</h1>
                    <br>
                    <h3>                       
                        <h:outputLink value="inserir.jsp">
                            <f:verbatim>Inserir</f:verbatim>
                        </h:outputLink>
                        <br><br>
                        <h:outputLink value="buscar.jsp">
                            <f:verbatim>Buscar</f:verbatim>
                        </h:outputLink>                        
                       
                    </h3>
                </center>
            </h:form>
        </f:view>
    </body>
</html>

e o erro q da é o seguinte.

org.apache.jasper.JasperException: Cannot find FacesContext

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

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

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

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

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

org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)

c alguem puder me ajudar agradeço muito…

4 Respostas

RaulCarlin

Posta seu faces-config e seu web aí… esse erro ocorre quando o servlet do JSF não tá configurado corretamente…

A

to postando os arquivos q não tinha postado antes… desde ja agradeço pela ajuda

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


<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config>
    <navigation-rule>
        <from-view-id>/sucesso_busca.jsp</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/buscar.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/index.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/buscar.jsp</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/sucesso_busca.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/falha_busca.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <from-view-id>/inserir.jsp</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/index.jsp</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>    
            
            <to-view-id>/index.jsp</to-view-id>
        </navigation-case>
    </navigation-rule>
    
    <managed-bean>
        <managed-bean-name>agenda</managed-bean-name>
        <managed-bean-class>teste.AgendaDB</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    
    <managed-bean>
        <managed-bean-name>testando</managed-bean-name>
        <managed-bean-class>teste.agenda2</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    
    
    
</faces-config>

e o web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <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>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
	<welcome-file>
            index.jsp
        </welcome-file>
    </welcome-file-list>
</web-app>
R

Como vocE esta usando JSF, voce precisa chamar as suas paginas com o padrao definido no seu web.xml.

/faces/*

entao, la no navegador voce chama a pagina da seguinte forma… exemplo

http://localhost:8080/Aplicacao/faces/

Espero ter ajudado.

Abraco

Rodrigo

gigicantador

Está faltando a configuração do listener no seu web.xml

Se estiver usando a biblioteca da sun:

&lt;listener&gt; &lt;listener-class&gt; com.sun.faces.config.ConfigureListener &lt;/listener-class&gt; &lt;/listener&gt;

Se estiver usando a myfaces:

&lt;listener&gt; &lt;listener-class&gt; org.apache.myfaces.webapp.StartupServletContextListener &lt;/listener-class&gt; &lt;/listener&gt;

Aliás, você colocou os jars das bibliotecas necessárias no seu WEB-INF/lib??

Para uma aplicação básica JSF você precisa:

commons-digester.jar

common-annotations.jar

commons-beanutils.jar

commons-logging.jar

jsf-api.jar

jsf-impl.jar

jstl.jar

standard.jar

Criado 21 de junho de 2008
Ultima resposta 22 de jun. de 2008
Respostas 4
Participantes 4