JSF - Exception: FacesContext

11 respostas
F

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.

11 Respostas

T

cara tem alguma coisa errada no seu web.xml

posta ele aí pra gente dah uma olhada.

felipeguerra

Posta o faces-config também!

F

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.

Marky.Vasconcelos

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^^

F

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.

felipeguerra

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

B

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

blackthorne

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.

R
<?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

R

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.

R

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

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

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

<faces-config version="1.2" 
    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">
    <application>
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
    </application>
    
    <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>
</faces-config>
<?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">
    <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>
		<url-pattern>*.faces</url-pattern>
		<url-pattern>*.jsp</url-pattern>
	</servlet-mapping>
	
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
<%@ 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"%>
<!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>
Teste
</body>
</html>
Criado 20 de dezembro de 2007
Ultima resposta 20 de ago. de 2013
Respostas 11
Participantes 9