tente limpar o seu web.xml colocando somente os campos essenciar para executar a base do seu projeto e depois vai colocando o restante da configuração é o jeito mais facil de achar o erro
Re:JSF + FACESCONTEXT
2 Respostas
Quando tento rodar minha aplicação esta gerando esse erro:
org.apache.jasper.JasperException: Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml configuration fileand if you are accessing your jsf-pages through the correct mapping. E.g.: if your FacesServlet is mapped to *.jsf (with the-element), you need to access your pages as 'sample.jsf'. If you tried to access 'sample.jsp', you'd get this error-message. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395) 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:810) org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) root cause
javax.faces.FacesException: Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml configuration fileand if you are accessing your jsf-pages through the correct mapping. E.g.: if your FacesServlet is mapped to *.jsf (with the
-element), you need to access your pages as 'sample.jsf'. If you tried to access 'sample.jsp', you'd get this error-message.
javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:926)
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:313)
org.apache.jsp.jsp.login_jsp._jspx_meth_h_commandLink_0(login_jsp.java:92)
org.apache.jsp.jsp.login_jsp._jspService(login_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
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:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
Meu 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">
<display-name>sisrs</display-name>
<context-param>
<description>Comma separated list of URIs of (additional) faces config files.
(e.g. /WEB-INF/my-config.xml)
See JSF 1.0 PRD2, 10.3.2
Attention: You do not need to put /WEB-INF/faces-config.xml in here.
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/managed-bean-config.xml</param-value>
</context-param>
<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>
<description>This parameter tells MyFaces if javascript code should be allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default: "true"
</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that it is "human readable".
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default: "true"
</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
Validate managed beans, navigation rules and ensure that forms are not nested.
</description>
<param-name>org.apache.myfaces.VALIDATE</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>
<context-param>
<description>
A very common problem in configuring MyFaces-web-applications
is that the Extensions-Filter is not configured at all
or improperly configured. This parameter will check for a properly
configured Extensions-Filter if it is needed by the web-app.
In most cases this check will work just fine, there might be cases
where an internal forward will bypass the Extensions-Filter and the check
will not work. If this is the case, you can disable the check by setting
this parameter to false.
</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Change the url-pattern from the ExtensionsFilter
Default is "/faces/myFacesExtensionResource"
Note: The filter-mapping for ExtensionsFilter, the url-pattern is
this value + "/*", else there comes a exception
</description>
<param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
<param-value>/faces/extensionResource</param-value>
</context-param>
<context-param>
<description>
This parameter enables partial state saving.
</description>
<param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true every time a page is rendered, the corresponding JSP is dispatched also.
This is very usefull if Scriptlets are used inside the JSP.
</description>
<param-name>javax.faces.PARTIAL_STATE_SAVING_DISPATCH_EVERY_TIME</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>dir.upload</param-name>
<param-value>/temp/</param-value>
</context-param>
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes, 10k - 10 KB, 10m - 10 MB, 1g - 1 GB
</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes, 10k - 10 KB, 10m - 10 MB, 1g - 1 GB
</description>
<param-name>uploadThresholdSize</param-name>
<param-value>250k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<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.html</welcome-file>
</welcome-file-list>
<resource-ref>
<res-ref-name>jdbc/MySqlDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<mime-mapping>
<extension>csv</extension>
<mime-type>application/csv</mime-type>
</mime-mapping>
<error-page>
<error-code>403</error-code>
<location>/erroLogin.html</location>
</error-page>
</web-app>
Meu faces-config.xml
<?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">
<faces-config>
<application>
<locale-config>
<default-locale>pt_BR</default-locale>
<supported-locale>pt_BR</supported-locale>
</locale-config>
<message-bundle>sisfmanager</message-bundle>
</application>
<navigation-rule>
<from-view-id>/jsp/login.jsp</from-view-id>
<navigation-case>
<from-outcome>sucesso</from-outcome>
<to-view-id>/jsp/principal/index.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
<!DOCTYPE html PUBLIC "-//W3C//Dli XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Dli/xhtml1-transitional.dli">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
[color=red] [b] <f:verbatim><h1>teste</h1></f:verbatim>[/b] [/color]
</body>
</html>
Boa noite,
despois de muita pesquisa, e sem solução alguma resolvi estudar jsf um pouco…
Então descobri que é necessario passar por dentro do contexto /faces/ pra “ativar” o faces context e conseguir utilizar de seus recursos.
Então modifiquei meu web.xml para atender isso colocando assim:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
e meu index.html
<script language="JavaScript">
window.open("/sisf/faces/jsp/login.jsp",'popupImageWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=800,height=600,screenX=150,screenY=150,top=150,left=150')
window.close();
</script>
Note que passo por dentro do contexto /faces/ a partir dai consigo utilizar de todos os recursos dele.
Abraços.