- This topic has 1 reply, 2 voices, and was last updated 11 years, 9 months ago by support-pradeep.
-
AuthorPosts
-
TriciaParticipantHello
I was trying to run the JSF Tutorial, however when I tried to run the application on the server it gave me the following error:
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.RuntimeException: Cannot find FacesContext
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1852)
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1669)
at org.apache.jsp.userLogin_jsp._jspx_meth_f_005fview_005f0(userLogin_jsp.java:141)
at org.apache.jsp.userLogin_jsp._jspService(userLogin_jsp.java:115)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)I did enable my web project for JSF capabilities and I am using the .faces extension when referencing the userLogin.faces page. I did a search on some of the forms and I think I may need to remap my web.xml file, but I’m not sure how to go about that. I guess I thought that would automatically happen when enabling the JSF capabilities for the web project. I am using the myEclipse10 version, and was just following the JSF tutorial. Here is my current
web.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”3.0″
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_3_0.xsd”>
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
and faces.config.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<faces-config version=”2.0″ 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_2_0.xsd”>
<managed-bean>
<managed-bean-name>UserBean</managed-bean-name>
<managed-bean-class>com.jsfdemo.bean.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>password</property-name>
<value/>
</managed-property>
<managed-property>
<property-name>username</property-name>
<value/>
</managed-property>
</managed-bean>
<navigation-rule>
<from-view-id>/userLogin.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/userLoginSuccess.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/userLogin.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/userLoginSuccess.jsp</from-view-id>
</navigation-rule>
</faces-config>Please Help 🙂
support-pradeepMembertricia0130,
I could not replicate the issue at our end on MyEclipse 10.7.1 after following this tutorial – http://www.myeclipseide.com/documentation/quickstarts/jsf/
From your web.xml code, it is observed that the servlet mapping for “Faces servlet” is not done. Can you please paste the following code in web.xml and check whether you can run the application :
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” version=”2.4″ 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>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>When you follow the tutorial, the web.xml will be automatically updated. There is no need for you to edit the web.xml file while following the tutorial.
If you are still facing issues, please download the JSFdemo project from the following link and import it into your workspace and check whether you can run the application : http://www.myeclipseide.com/documentation/quickstarts/jsf/JSFLoginDemo.zip
Let us know how it works for you.
-
AuthorPosts