JSF - Exception: FacesContext

Estou com problema ao executar meu projeto no netbeans me retorna com o erro:

HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext

root cause

java.lang.RuntimeException: Cannot find FacesContext

note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.

Gostaria de saber se alguém sabe resolver esse problema?
Grato.

cara tem alguma coisa errada no seu web.xml

posta ele aí pra gente dah uma olhada.

Posta o faces-config também!

Dá uma olhada no web.xml, especificamente em servlet-mapping.

Provavelmente deve estar assim:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

Se estiver como acima, acrescente “faces” no final da url: http://localhost:8080/seuprojeto/faces/index.jsp

Espero ter ajudado (sou iniciante)

Marco A.

Se tiver assim

<servlet-mapping> 
<servlet-name>Faces Servlet</servlet-name> 
<url-pattern>/faces/*</url-pattern> 
</servlet-mapping> 

Por que não deixa um pouco mais bonito

<servlet-mapping> 
<servlet-name>Faces Servlet</servlet-name> 
<url-pattern>*.jsf</url-pattern> 
</servlet-mapping> 

Acho bem legal escreveras urlse colocar .jsf no final^^

Eu refiz o projeto novamente e abriu normalmente o jsp, porém não está se conectando com o Banco de Dados, porque quando efetua a pesquisa, me retorna com se não tivesse nenhum registro.

Segue o fonte abaixo:

context.xml do META-INF:

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

faces-config.xml

<?xml version="1.0"?> /buscar.jsp

success

/sucesso_busca.jsp

failure

/falha_busca.jsp

cidades jee.model.ClassBusca session

web.xml

<?xml version="1.0" encoding="UTF-8"?> com.sun.faces.verifyObjects false com.sun.faces.validateXml true javax.faces.STATE_SAVING_METHOD client Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet /faces/* 30
<resource-ref>
<res-ref-name>jdbc/db_pool_jsf</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<welcome-file-list>
    <welcome-file>faces/buscar.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Grato.

já simulei tirar esse fonte do projeto e pelo o que consta ele gerou a mesma msg, que não existe nenhum caracter dentro do campo da tabela.

Ou djow, edita seu post e coloca o código dentro da tag Code!

Amigo estava com problema identico…
e a configuracao do servidor…
qual e a IDE que vc usa??
Se for o NetBeans fiaca na aba de servidores…
espero que ajude…
Cristiano Brito

tu tem q ver o padrao url definido no teu faces-config

por exemplo, tenho

Persistent Faces Servlet *.iface

entao acesso index.ifaces

se tu tentar index.jsp por exemplo e a pagina sendo inde.jspx vai dar erro.
eh algo asism…
tenta ai.

<?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">
    <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>*.jsf</url-pattern>
    </servlet-mapping>

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

    <session-config>
        <session-timeout>40</session-timeout>
    </session-config>

</web-app>

Esta é a configuração básica

Para mim estava dando esse erro quando estava tentando rodar o jsp. Coloquei no web.xml <url-pattern>*.jsp</url-pattern> e rodou. Só que agora está dando. Error Parsing /CadastraPessoa.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.

Encontrei uma sugestão em http://www.guj.com.br/java/134126-erro-bobo-hibernate-xml—the-markup-in-the-document-preceding-the-root ajustei o enconding tudo para utf-8. Mas não tá rolando. Ainda estou tentando descobrir.

Ainda continuo com o erro acima. Se alguém puder me ajudar agradeço.

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



com.sun.facelets.FaceletViewHandler

<managed-bean>
    <managed-bean-name>PessoaMB</managed-bean-name>
    <managed-bean-class>br.com.softboxProva.MB.PessoaMB</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>
[/code]

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


Faces Servlet
javax.faces.webapp.FacesServlet
1


Faces Servlet
.jsf
.faces
*.jsp

<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
[/code]

[code]<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“ISO-8859-1”%>
<%@ taglib uri=“http://richfaces.org/a4j” prefix=“a4j”%>
<%@ taglib uri=“http://richfaces.org/rich” prefix=“rich”%>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h”%>
<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f”%>

Insert title here Teste [/code]