aspose file tools*
The moose likes JSF and the fly likes JSF - JasperException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF - JasperException" Watch "JSF - JasperException" New topic
Author

JSF - JasperException

John teras
Greenhorn

Joined: Jun 26, 2009
Posts: 6
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: An exception occurred processing JSP page /jsp/data.jsp at line 11

8:
9: </head>
10: <body>
11: <f:view>
12: <center>

13:

14:



Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find FacesContext
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.jsp.data_jsp._jspService(data_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.jsp.JspException: Cannot find FacesContext
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:399)
com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
org.apache.jsp.jsp.data_jsp._jspx_meth_f_005fview_005f0(data_jsp.java:108)
org.apache.jsp.jsp.data_jsp._jspService(data_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Can somebody let me know the solution for this exception
Tomasz Lipinski
Greenhorn

Joined: Nov 05, 2008
Posts: 6
Do you open your page using jsp or jsf extension? I think there is the problem. File name is data.jsp but if you want JSF to open it type data.jsf in address field.
John teras
Greenhorn

Joined: Jun 26, 2009
Posts: 6
Extension is jsp. I have used the JSF tags libray in the jsp page. And on"<f:view>", Container throws exception.
Tomasz Lipinski
Greenhorn

Joined: Nov 05, 2008
Posts: 6
Ok your file is named data.jsp, that's ok, but what do you type in your address field? It should be something like http://localhost:8080/data.jsf . jsf at the end, not jsp!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Amitgggggggg,

We don't have a whole lot of rules here at the JavaRanch, but one we do insist on is that you use a real name. I know that there's a good chance someone's already using a name like "Amit Gupta", but could you try and come up with something a little more professional-looking? Thanks!

JSF can only managed by the FacesServlet. That means that in your web.xml file, you need to have defined an instance of the FacesServelt and set up a URL mapping to route the JSF page requests to it. The routing part is essential, because unlike a lot of the old-time desktop frameworks, JSF isn't in continuous control of the application - you can mix JSF, plain old JSP, Struts and custom servlets all in the same app.


Customer surveys are for companies who didn't pay proper attention to begin with.
John teras
Greenhorn

Joined: Jun 26, 2009
Posts: 6
I have done all the configuration in both web.xml and faces-config.xml. Below code for web.xml:

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

Mapping are correct. Can anybody let me know, In which scenarios, JasperException comes?

Thanks...!
Tomasz Lipinski
Greenhorn

Joined: Nov 05, 2008
Posts: 6
Sorry, I assumed that you have *.jsf url-pattern in your mapping. In this case you should either open page using data.faces or change pattern to whatever you like best.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

Jasper is the JSP compiler. Your exception was thrown because the JSP tag processors generated a reference to the FacesContext object, but that object only gets created when the page was processed by the FacesServlet. It gets created and destroyed for each HTTP request.

Your URL pattern only routes URLs ending with ".faces". So to route properly, your URL would have to be /jsp/data.faces . This would cause the URL to get routed to the FacesServlet, which would then decode it, replacing the ".faces" with ".jsp" and process your faces.jsp page properly.
John teras
Greenhorn

Joined: Jun 26, 2009
Posts: 6
thanks Tim, Its working
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF - JasperException
 
Similar Threads
Struts 1.2 not working properly in jboss-5.0.0.CR1
JSF error
Cannot find ActionMappings or ActionFormBeans collection
Getting an Exception in JSP code.
when iam running my struts application following error comes please help me