-
1. Re: erro: Cannot find FacesContext
ilya40umov Jan 4, 2011 9:52 AM (in response to natasha25)Please, add the full stack trace and your code.
-
2. Re: erro: Cannot find FacesContext
natasha25 Jan 4, 2011 11:35 AM (in response to ilya40umov)Hello,
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"> <display-name>Greeter</display-name> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <context-param> <param-name>org.richfaces.CONTROL_SKINNING</param-name> <param-value>enable</param-value> </context-param> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <listener> <listener-class>com.sun.faces.config.ConfigureListener</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>*.jsf</url-pattern> </servlet-mapping> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>
face-config.xml<?xml version="1.0" encoding="UTF-8"?> <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" 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"> <managed-bean> <description>UsernName Bean</description> <managed-bean-name>user</managed-bean-name> <managed-bean-class>demo.user</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>name</property-name> <property-class>java.lang.String</property-class> <value/> </managed-property> </managed-bean> </faces-config>
index.jsp<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <!-- RichFaces tag library declaration --> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%> <html> <head> <title>RichFaces Greeter</title> </head> <body> <f:view> <a4j:form> <rich:panel header="RichFaces Greeter" style="width: 315px"> <h:outputText value="Your name: " /> <h:inputText value="#{user.name}" > <f:validateLength minimum="1" maximum="30" /> </h:inputText> <a4j:commandButton value="Get greeting" reRender="greeting" /> <h:panelGroup id="greeting" > <h:outputText value="Hello, " rendered="#{not empty user.name}" /> <h:outputText value="#{user.name}" /> <h:outputText value="!" rendered="#{not empty user.name}" /> </h:panelGroup> </rich:panel> </a4j:form> </f:view> </body> </html>
Erro:StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exceptionjava.lang.RuntimeException: Cannot find FacesContextat javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)at org.apache.jsp.index_jsp._jspx_meth_f_view_0(index_jsp.java from :133)at org.apache.jsp.index_jsp._jspService(index_jsp.java from :105)at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:406)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:483)at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:373)at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)at com.sun.grizzly.ContextTask.run(ContextTask.java:69)at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)at java.lang.Thread.run(Thread.java:619) -
3. Re: erro: Cannot find FacesContext
ilya40umov Jan 4, 2011 11:43 AM (in response to natasha25)It seems that I understand what is causing your problem. What application server are you using? Is it Glassfish 3.0.1? Because Glassfish 3.0.1 provides JSF 2.0 implementation but not JSF 1.2. So that you should probably read this article http://community.jboss.org/wiki/RichFaces333andJSF20.
-
4. Re: erro: Cannot find FacesContext
ilya40umov Jan 4, 2011 1:45 PM (in response to ilya40umov)I looked at these links:
http://www.coderanch.com/t/214435/JSF/java/JSF-as-RuntimeException-Cannot-find
http://www.coderanch.com/t/509611/JSF/java/jsf-java-lang-RuntimeException-Cannot
http://www.coderanch.com/t/522091/JSF/java/java-lang-RuntimeException-Cannot-find
And I think that you may have a conflict between JSF implementations. Look into links for details.
-
5. Re: erro: Cannot find FacesContext
natasha25 Jan 5, 2011 10:02 AM (in response to natasha25)Thanks for you replay I include in my web.xml this code<welcome-file-list><welcome-file>faces/index.jsp</welcome-file></welcome-file-list>Thanks for you replay I include in my web.xml this code
<welcome-file-list>
<welcome-file>faces/index.jsp</welcome-file>
</welcome-file-list>
-
6. Re: erro: Cannot find FacesContext
natasha25 Jan 5, 2011 10:02 AM (in response to natasha25)I Got, thanks