• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot find FacesContext

 
RalphMichelsen Michelsen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone

I am rather new to jsf and I have run into a big black hole ;-)

After I have deployed my app. and I call my bankUI.jsp through my jsf mapping I get the following error:

javax.servlet.jsp.JspException: Cannot find FacesContext
javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405)
org.apache.myfaces.taglib.core.ViewTag.doStartTag(ViewTag.java:71)
... rest of stacktrace ....


This is my setup:

App.server: jboss-4.0.4RC1

web.xml:
<!-- 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-client.war (struture)

bankUI.jsp
meta-inf
manifest.mf
web-inf
faces-config.xml
web.xml
classes
...sourcefiles...
lib
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
jstl.jar
standard.jar

bankUI.jsp:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<title>
jboss_tutorial
</title>
<head> </head>

<body>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<f:view>

<h:form id="form">
<h utputText id="overskrift" value="Ralph�s Bank" style="font-family:Arial, sans-serif; font-size=24;color=green"/>
<h utputLabel for="cprsoeg">
<h utputText id="cprsoegtext" value="Soeg cprnr."/>
</h utputLabel>
<h:inputText id="cprsoeg" value="#{bankUIBean.cprnr}" required="true">
<f:validateLongRange minimum="10" maximum="10"/>
</h:inputText>
<h:message id="errors" for="cprsoeg" style="color:red" />
</h:form>



</f:view>

</body>
</html>

There are no errors on deployment, and my app. runs find. But when i try to acces my bankUI.jsp i get the error above.
And I do go through the correct jsf mapping http://localhost:8080/project_1app/bankUI.jsf

Now if I remove all my jsf related tags from my jsp file (bankUI.jsp) the page is displayed correct. So the error occurs when i hit the first jsf tag on my jsp page.

I also run ejb3.0 on my jboss app server. I don't know if that is usefull information.

PLEASE HELP




Ralph Michelsen
 
A Saari
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mine looks like:

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

amy
 
RalphMichelsen Michelsen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Amy

Thanks for your reply.

How ever I have already tried a different mapping in my web.xml, but this did not solve my problem

I believe that my jboss app. server for some reason does not start up an instance of the facesservlet. I have not found the solution yet, but I am stilling searching

regards Ralph
 
Mohammad Ibrahim
Ranch Hand
Posts: 51
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ralph,
have you tried to deploy your application on some other server. I deploy my JSF applications in Tomcat 5.0 and it works absolutely fine.
My web.xml reads as follows (my sample app had Struts capabilities):

 
RalphMichelsen Michelsen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, thank you for your respons.

I have solved my problem with a little help from a guy at Sun jsf Forums.

He wrote the following very helpfull lines
As for your other problems, make sure you don't have multiple versions of the JSF libs in your app. If you're running on JBoss, you'll likely have all the JBoss libs in $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/jsf-libs

If you package another set of JSF libs in your WEB-INF/lib directory this can cause the kind of problem you're seeing. So, in short, make sure that the above directory contains the MyFaces JSF impl and ensure that you're not packaging another set of JSF jars in your ear.


This was exactly my problem. I had a different set of jsf jars in my web-inf/lib than in the JBOSS installation. When I corrected this, there were no problems anymore.

Thanks all.

Ralph
 
Paul Suchko
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This also happens if you try running the underlying JSP file without using the correct extension which causes the Faces servlet to be invoked first (e.g. xxx.jsp instead of xxx.iface)
 
sancho sebastine
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tips. It helped. I had the same problem.

I found that it was because my file was named as sample.jsp and not sample.jspx. When i renamed the file as sample.jspx everything was fixed. I created the file in eclipse and it had automatically named with .jsp extension. If you are working with eclipse you might want to look at this.

Hope it helps someone
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic