permaculture playing cards*
The moose likes JSF and the fly likes Problems with running JSF in Eclipse 3.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Problems with running JSF in Eclipse 3.1" Watch "Problems with running JSF in Eclipse 3.1" New topic
Author

Problems with running JSF in Eclipse 3.1

Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Hello,

I am a programmer and pretty much new to the JSF technology.

I have a problem running an example from a book, "Beginning Java EE 5".

Hope somebody can help out.

**************************************************************************

First the error message I get:


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: Exception in JSP: /searchForm.jsp:12

9: <meta http-equiv="Content-Type" content="text/html; charset=ISO-
10:
11: <html>
12: <f:view>
13: <head>
14: <title>Freedom Airlines Online Flight Reservation System</title>
15: </head>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause

javax.servlet.ServletException: Cannot find FacesContext
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.searchForm_jsp._jspService(searchForm_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


root cause

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)
org.apache.jsp.searchForm_jsp._jspx_meth_f_view_0(searchForm_jsp.java:98)
org.apache.jsp.searchForm_jsp._jspService(searchForm_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.16 logs.


**************************************************************************

Here's my web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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/web-app_2_5.xsd"
version="2.5">

<display-name>Jsf_Ex01 - Simple JSF Application</display-name>

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

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>

**************************************************************************
Here's my faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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/web-facesconfig_1_2.xsd"
version="1.2">

<navigation-rule>
<from-view-id>/searchForm.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/searchResults.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>

<managed-bean>
<managed-bean-name>flight</managed-bean-name>
<managed-bean-class>jsf.test1.FlightSearch</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>


**************************************************************************
Here's my index.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Flight Search</title>
</head>
<body>
<meta http-equiv="Refresh" content= "0; URL=searchForm.faces"/>
</body>
</html>

***************************************************************************

Here is my first jsf page, searchForm.jsf:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-

<html>
<f:view>
<head>
<title>Freedom Airlines Online Flight Reservation System</title>
</head>
<body>
<h:form>
<h2>Search Flights</h2>
<table>
<tr><td colspan="4">Where and when do you want to travel?</td></tr>
<tr>
<td colspan="2">Leaving from:</td>
<td colspan="2">Going to:</td>
</tr>
<tr>
<td colspan="2">
<h:inputText value="#{flight.origination}" size="35"/>
</td>
<td colspan="2">
<h:inputText value="#{flight.destination}" size="35"/>
</td>
</tr>

<tr>
<td colspan="2">Departing:</td>
<td colspan="2">Returning:</td>
</tr>
<tr>
<td>
<h:inputText value="#{flight.departDate}"/>
</td>
<td>
<h:inputText value="#{flight.departTime}"/>
</td>
<td>
<h:inputText value="#{flight.returnDate}"/>
</td>
<td>
<h:inputText value="#{flight.returnTime}"/>
</td>
</tr>
</table>
<p>
<h:commandButton value="Search" action="submit"/>
</p>
</h:form>
</body>
</f:view>
</html>

***************************************************************************

Here is my second jsf page, searchResults.jsf:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<html>
<f:view>
<head>
<title>Freedom Airlines Online Flight Reservation System</title>
</head>
<body>
<h3>You entered these search parameters</h3>
<p>Origination: <h utputText value="#{flight.origination}"/>
<p>Depart date: <h utputText value="#{flight.departDate}"/>
<p>Depart time: <h utputText value="#{flight.departTime}"/>
<p>Destination: <h utputText value="#{flight.destination}"/>
<p>Return date: <h utputText value="#{flight.returnDate}"/>
<p>Return time: <h utputText value="#{flight.returnTime}"/>
<p>Trip type : <h utputText value="#{flight.tripType}"/>
</body>
</f:view>
</html>

</body>
</html>

***************************************************************************
And here's my java bean, FlightSearc.java:

package jsf.test1;

public class FlightSearch {
String origination;
String destination;
String departDate;
String departTime;
String returnDate;
String returnTime;

public String getDepartDate() {
return departDate;
}

public void setDepartDate(String departDate) {
this.departDate = departDate;
}

public String getDepartTime() {
return departTime;
}

public void setDepartTime(String departTime) {
this.departTime = departTime;
}

public String getDestination() {
return destination;
}

public void setDestination(String destination) {
this.destination = destination;
}

public String getOrigination() {
return origination;
}

public void setOrigination(String origination) {
this.origination = origination;
}

public String getReturnDate() {
return returnDate;
}

public void setReturnDate(String returnDate) {
this.returnDate = returnDate;
}

public String getReturnTime() {
return returnTime;
}

public void setReturnTime(String returnTime) {
this.returnTime = returnTime;
}
}

***************************************************************************

Can somebody please help? I've been debugging it for hours and I can't find the error. I have placed all 6 JSF jars inside the WEB-INF/lib directory, placed them inside my Java build path, and inluded them in my packaging cofigurations - but still I get an error message. I am thinking it might be with some configurations in Eclipse that I missed out. Please help, 'coz I really need to get to the next sections of this book. Thanks a lot.

-eugene


There's so much to learn in this industry, and not everybody has the necessary interest.
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>


So, you have to use .faces , but not .jsf or .jsp in your URL.

Try SearchForm.faces
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
I have tried what you suggested, but it still shows the same error.

Here's my url:
http://localhost:8080/JSF1/searchForm.faces


on the verge of desperation,
-eugene
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Also my colleague suggested that a MyEclipse plugin is needed for JSF to work in Eclipse 3.0. Can somebody confirm this? Tnx.

-eugene
Milind Patil
Greenhorn

Joined: Oct 19, 2003
Posts: 26
Something is wrong in this code,
I am giving the whole working code here,

index.html
---------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Flight Search</title>
</head>
<body>
<meta http-equiv="Refresh" content= "0; URL=searchForm.faces"/>
</body>
</html>
-----------------------------------------------------
searchForm.jsp
-----------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-

<html>
<f:view>
<head>
<title>Freedom Airlines Online Flight Reservation System</title>
</head>
<body>
<h:form>
<h2>Search Flights</h2>
<table>
<tr><td colspan="4">Where and when do you want to travel?</td></tr>
<tr>
<td colspan="2">Leaving from:</td>
<td colspan="2">Going to:</td>
</tr>
<tr>
<td colspan="2">
<h:inputText value="#{flight.origination}" size="35"/>
</td>
<td colspan="2">
<h:inputText value="#{flight.destination}" size="35"/>
</td>
</tr>

<tr>
<td colspan="2">Departing:</td>
<td colspan="2">Returning:</td>
</tr>
<tr>
<td>
<h:inputText value="#{flight.departDate}"/>
</td>
<td>
<h:inputText value="#{flight.departTime}"/>
</td>
<td>
<h:inputText value="#{flight.returnDate}"/>
</td>
<td>
<h:inputText value="#{flight.returnTime}"/>
</td>
</tr>
</table>
<p>
<h:commandButton value="Search" action="submit"/>
</p>
</h:form>
</body>
</f:view>
</html>
---------------------------------------------------------
searchResults.jsp
---------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<html>
<f:view>
<head>
<title>Freedom Airlines Online Flight Reservation System</title>
</head>
<body>
<h3>You entered these search parameters</h3>
<p>Origination: <h utputText value="#{flight.origination}"/>
<p>Depart date: <h utputText value="#{flight.departDate}"/>
<p>Depart time: <h utputText value="#{flight.departTime}"/>
<p>Destination: <h utputText value="#{flight.destination}"/>
<p>Return date: <h utputText value="#{flight.returnDate}"/>
<p>Return time: <h utputText value="#{flight.returnTime}"/>
<p>Trip type : <h utputText value="#{flight.tripType}"/>
</body>
</f:view>
</html>

</body>
</html>
-----------------------------------------------------
faces-config.xml
-----------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>
<navigation-rule>
<from-view-id>/searchForm.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/searchResults.jsp</to-view-id><to-view-id/>
</navigation-case>
</navigation-rule>

<managed-bean>
<managed-bean-name>flight</managed-bean-name>
<managed-bean-class>jsf.test1.FlightSearch</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
--------------------------------------------------
web.xml
--------------------------------------------------
<?xml version='1.0' encoding='UTF-8'?>

<!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>
<display-name>Jsf_Ex01 - Simple JSF Application</display-name>

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

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>

-----------------------------------------
FlightSearch.java
-----------------------------------------
package jsf.test1;

public class FlightSearch {
String origination;
String destination;
String departDate;
String departTime;
String returnDate;
String returnTime;

public String getDepartDate() {
return departDate;
}

public void setDepartDate(String departDate) {
this.departDate = departDate;
}

public String getDepartTime() {
return departTime;
}

public void setDepartTime(String departTime) {
this.departTime = departTime;
}

public String getDestination() {
return destination;
}

public void setDestination(String destination) {
this.destination = destination;
}

public String getOrigination() {
return origination;
}

public void setOrigination(String origination) {
this.origination = origination;
}

public String getReturnDate() {
return returnDate;
}

public void setReturnDate(String returnDate) {
this.returnDate = returnDate;
}

public String getReturnTime() {
return returnTime;
}

public void setReturnTime(String returnTime) {
this.returnTime = returnTime;
}

public void searchFlight()
{

}
}



check following jars in your WEB-INF\lib dir,
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-lang.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
jstl.jar
standard.jar



that's it... your application will run.



Regards,
Milind


Milind B. Patil - SCJP-1.4, SCWCD-5.0, SCBCD-5.0
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Hi Milind,

I have tried what you suggested, but it is still generating the same error. What was it that you changed in the code? (That code by the way was copy and pasted from the book).

I am wondering also about the commons-lang.jar file. In the book that I was reading, there are only 6 jar files that should be added to the WEB-INF/lib folder, namely:

commons-beanutils.jar,
commons-collections.jar,
commons-digester.jar,
commons-logging.jar,
jsf-api.jar,
and jsf-impl.jar

plus of course the two jstl jar files. Also on my downloaded jsf, there were only 6 jars. Was that just a typo or did i really miss out that jar?

Tnx.

-eugene
JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
When you want to access a JSP page with JSF components, you need to do the following:

<%=application.getContextPath%>/faces/*.jsp.

I have solved this kind of an error last two days.


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Originally posted by JayaSiji Gopal:

<%=application.getContextPath%>/faces/*.jsp.


Where should you put this piece of code exactly? Inside the your jsp? Tnx.

-eugene
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Does anybody out there know how to configure JSF in Eclipse 3.1?

I am using the following:

IDE: Eclipse 3.1
APPLICATION SERVER: JBoss 4 (with Tomcat as Container)

I have been trying to write JSF in Eclipse, but nothing seems to work right. I have been getting the same error I mentioned above. I tried writing the code manually, that is, not using Eclipse IDE and JSF works out fine. So the problem is definitely in the configuration of Eclipse. I have placed all the JSF and JSTL jars inside my WEB-INF/lib directory, included them in the java build path, and included it in my packaging configuration. Did I miss out anything? Any form of advice will be a big help. Tnx in advance!

-eugene
ved gunjan
Ranch Hand

Joined: May 17, 2003
Posts: 86
hi,
i worked on a poc (proof of concept)with jboss4.04/jsf/myeclipse environment and also faced the same issue.
u should do this in order to fix the exception:
go to the following directory of jboss.
<jboss-home>\server\default\deploy\jbossweb-tomcat55.sar
and delete the jsf-libs folder.
u should have the jsf libraries in your classpath..i.e in the lib folder of your web application.

try this... it worked with me...
thnx
Eugene Abarquez
Ranch Hand

Joined: May 18, 2006
Posts: 211
Originally posted by ved gunjan:

u should do this in order to fix the exception:
go to the following directory of jboss.
<jboss-home>\server\default\deploy\jbossweb-tomcat55.sar
and delete the jsf-libs folder.
u should have the jsf libraries in your classpath..i.e in the lib folder of your web application.


Hi Ved!

Your suggestion solved my problem! I have been stumped with this problem for the last three days. I figured it might be some configurations with Eclipse, but I just couldn't find what to change. Thank you so much! Hope it might also help somebody out there with the same problem! Thanks guys!

Eugene
mohan rajv
Ranch Hand

Joined: Jan 28, 2009
Posts: 30
in the same scenario am getting this error :

HTTP Status 404 - /LearningJSF/index.jsf

--------------------------------------------------------------------------------

type Status report

message /LearningJSF/index.jsf

description The requested resource (/LearningJSF/index.jsf) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.17


Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.NoClassDefFoundError: javax/el/CompositeELResolver
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3678)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)................(etc)



what might be the problem..?
is it the problem with the jar files?
actually what are the jar files required to run JSF1.1 in eclipse3.3.2 using jboss4.0.4 ?
thnx..
 
 
subject: Problems with running JSF in Eclipse 3.1
 
Similar Threads
Problems in JSF running with MyEclipse
my first jsf app is giving error, can someone please help me!
form and address do not match.
Can't instantiate a class
Two MyFaces problems