I am learning JSF and got help from Exadel.com. I followed the steps described there.
The web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>FBApp</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<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>
<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>
</web-app>
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 http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<navigation-rule>
<from-view-id>/pages/inputname.jsf</from-view-id>
<navigation-case>
<from-outcome>greeting</from-outcome>
<to-view-id>/pages/greeting.jsf</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>personBean</managed-bean-name>
<managed-bean-class>com.fbapp.bean.PersonBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config>
index.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index</title>
</head>
<body>
<jsp:forward page="faces/pages/inputname.jsf" />
</body>
</html>
inputname.jsp:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>enter your name page</title>
</head>
<body>
<f:view>
<h1>
<h:outputText value="JSF KickStart"/>
</h1>
<h:form id="helloForm">
<h:outputText value="Tell us your name"/>
<h:inputText value="#{personBean.personName}" />
<h:commandButton action="greeting" value="Say Hello" />
</h:form>
</f:view>
</body>
</html>
Now the difference present is:
- In index.jsp I used
<jsp:forward page="faces/pages/inputname.jsf" />and Exadel used<jsp:forward page="/pages/inputname.jsf" /> - I have used
<url-pattern>/faces/*</url-pattern>and they used :
<url-pattern>*.jsf</url-pattern>
The jar libraries are:
- commons-beanutils-1.7.0.jar
- commons-codec-1.3.jar
- commons-collections-3.1.jar
- commons-digester-1.7.jar
- commons-el-1.0.jar
- commons-fileupload-1.0.jar
- commons-lang-2.1.jar
- commons-logging-1.0.4.jar
- commons-validator-1.1.4.jar
- jsf-api-1.2.jar
- jsf-impl-1.2-NIGHTLY_20060227.jar
- jstl-1.1.2.jar
- oro-2.0.8.jar
- xml-apis-1.0.b2.jar
In JBoss 4.2.2GA (customised for JSF) I deployed the war its running but when I am trying to go to the url http://localhost:8080/FBApp/ the page is rendered as:

which is actually the code of inputname.jsf. What I am doing wrong? Any information will be appreciable.
Thanks and regards.
Edit:
Code changed as instructed by BalusC. Now I am getting exception and the stacktrace:
19:34:04,244 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:162)
at org.apache.jsp.pages.inputname_jsp._jspx_meth_f_005fview_005f0(inputname_jsp.java:104)
at org.apache.jsp.pages.inputname_jsp._jspService(inputname_jsp.java:77)
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:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
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:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:636)
19:34:04,245 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:162)
at org.apache.jsp.pages.inputname_jsp._jspx_meth_f_005fview_005f0(inputname_jsp.java:104)
at org.apache.jsp.pages.inputname_jsp._jspService(inputname_jsp.java:77)
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:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:694)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:665)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:63)
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:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
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.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:636)
This can happen if you gave your actual JSP files a
.jsfextension. In other words, you don’t have ainputname.jspfile in your web content folder, but actually ainputname.jsffile. This is Wrong. Those JSP files should keep their.jspextension in order to get processed by theJspServlet. Otherwise those files won’t be parsed as JSP at all and will end up as plain text in the webbrowser.You have changed the URL pattern of the
FacesServletto be/faces/*instead of (the more recommended)*.jsf. So you should change all URLs in the tutorial from/foo.jsfto/faces/foo.jsp, also in the forwards/includes and navigation cases. You should not change to/faces/foo.jsfand use the wrong extension in the actual files.Unrelated to the concrete problem: is there any particular reason that you’re reading a 6 year old JSF 1.1 targeted tutorial instead of a more recent JSF 2.0 targeted tutorial? JSF 1.1 has so many disadvantages and also the legacy JSP has been succeeded by Facelets since 1.5 years ago.
Update as per the comment on the question:
This exception can occur if the runtime classpath is polluted with different versioned JSF libraries. JBoss ships with JSF builtin already, so you should not be providing JSF libraries in webapp’s
/WEB-INF/libfolder. If it’s of a different version, it will likely collide with exceptions like above.Update 2 as per the question update:
Well, this is a nasty one and I haven’t seen it before. I’ll bet it to be caused by just a classpath pollution. JBoss 4.2.x ships with JSF 1.2 and JSTL 1.1 already builtin. Please remove jsf*.jar and jstl*.jar libraries from
/WEB-INF/lib. Please also remove all JSF-related<context-param>and<listener>entires fromweb.xml. The ones which you’ve as far are all the JSF 1.2 default already. It may or may not solve your concrete problem, but it should at least minimize the noise. Let me know.Update 3 as per the comments:
Much better. The
Cannot find FacesContexterror has an easy cause: theFacesServlethasn’t been invoked. So the request or forward URL didn’t match the URL pattern of theFacesServletat all. Assuming that you have still mapped yourFacesServleton an URL pattern of/faces/*and that you have a physical/pages/inputname.jspfile in your web content, then all yourindex.jspshould contain is the following single line (yes, get rid of all that irrelevant HTML as well)This way just calling
should work. If it doesn’t for some reason (let me know) then at least calling
must work.
Update 4 as per the comments:
Hmm, this is also new to me. How does your
web.xmlnow look like? This suggests that you’ve ajavax.faces.CONFIG_FILEScontext param with a wrong value offaces-config.xml. Try putting thejavax.faces.CONFIG_FILEScontext param with value of/WEB-INF/faces-config.xmlback in theweb.xml. Perhaps the JSF 1.2 impl used in JBoss has some bug related to this.