Jsf Error for simple jsf program in web application.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I am running simple jsf program using the below URL:
http://localhost:8080/Project/converter.jsp
So getting this error:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find FacesContext
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find FacesContext
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.converter_jsp._jspService(converter_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.jsp.JspException: Cannot find FacesContext
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405)
com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
org.apache.jsp.converter_jsp._jspx_meth_f_005fview_005f0(converter_jsp.java:98)
org.apache.jsp.converter_jsp._jspService(converter_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
then i tried to run web application by:
http://localhost:8080/Project/faces/converter.jsp
then i am getting Error:
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoSuchMethodError: javax.faces.render.ResponseStateManager.getState(Ljavax/faces/context/FacesContext;Ljava/lang/String;)Ljava/lang/Object;
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:340)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:515)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
So what is the possible cause for this error.
My web.xml file is as below
<web-app>
<display-name>JavaServer Faces Custom Components</display-name>
<description>
JavaServer Faces Custom Components
</description>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default
value is false.
</description>
</context-param>
<!--
PENDING: MapComponent and GraphComponent currently add
a default listener in their constructor, which can only
succeed if there is a FacesContext for the current request.
-->
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to verify that all of the application
objects you have configured (components, converters,
renderers, and validators) can be successfully created.
Default value is false.
</description>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<!-- Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
could any one figure out ? please.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
There is some version conflict in jar file ?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You have given the url-pattern
<url-pattern>*.faces</url-pattern>
<url-pattern>/faces/*</url-pattern>
The folowing 2 url should work for you based on your url-pattern
http://localhost:8080/Project/faces/converter.jsp
http://localhost:8080/Project/converter.faces
You can go through http://jsflessons.blogspot.com . It's good for beginners.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have tried both one but still getting the same error:
http://localhost:8080/Project/converter.faces
http://localhost:8080/Project/faces/converter.jsp
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoSuchMethodError: javax.faces.render.ResponseStateManager.getState(Ljavax/faces/context/FacesContext;Ljava/lang/String;)Ljava/lang/Object;
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:340)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:515)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
Run your application
http://localhost:8080/Project/converter.jsf
This will work.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoSuchMethodError: javax.faces.render.ResponseStateManager.getState(Ljavax/faces/context/FacesContext;Ljava/lang/String;)Ljava/lang/Object;
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:346)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:515)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:157)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
and run the application:
http://localhost:8080/Project/converter.jsf
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Where is your converter.jsp (folder)in the project?
are you using Eclipse + Tomcat?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I am using Tomcat but not running it from eclipse.
I am running Tomcat from outside.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have created a dynamic web project in eclipse.
It's seems like yours is a java project. I never tried running a java project on tomcat.
I strictly follow the steps mentioned in http://jsflessons.blogspot.com
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
and one more thing if i run any jsp page or html page then it is working perfectly.
http://localhost:8080/index.jsp is working !
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Actually i was using both the jar files from myfaces and jsf-api.jar from sun ...that was the problem . There was conflict ion bet the two jar files version..
So i removed the myfaces jar files from the lib project build path.. but again i was getting the same error..you can see my attachment in build project jar files..No one figured out this..
One of my friend today told me you are using both the jar files from sun and myfaces so you are getting error.
Then i have seen in console tomcat still logging the myfaces daetils as error..then i have deleted the myfaces jar files from lib dir of my project..
Finally its working now.
Thanks everybody !
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
| There's a way to do it better - find it. -Edison. A better tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |









