File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Frustranting inability to run the most basic JSF application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Frustranting inability to run the most basic JSF application" Watch "Frustranting inability to run the most basic JSF application" New topic
Author

Frustranting inability to run the most basic JSF application

Marcos Silvestri
Ranch Hand

Joined: Dec 06, 2009
Posts: 62

Hello folks from all over the world!

I'm someone new to the Java Server Faces technology with Richfaces, and similar to most things I try to do in the Java world, different from the Microsoft world where I've come from, nothing appears to work at first, it is usually hard for me to implement trivial things, even going across ready-made tutorials on the web, several of them by the way.

This time, I'm at work, trying to get up and running a basic JSF application once I need to test a Richfaces functionality, the <rich:fileUpload/>, in order to later on implement it in our application here.

I've followed along these tutorials, step-by-step:

1) http://www.roseindia.net/jsf/netbeans/create-jsf-application.shtml

2) http://www.roseindia.net/jsf/SimpleHelloByEnteringName.shtml

Particularly the second example, neither doing exactly like that step-by-step, nor downloading the sample would work for me. Ultimately, I attempted to create a brand new application inside Netbeans, with the appropriate template for JSF, and adapted the code to it, also importing the JARs for Richfaces, but no success at all. One curious thing is that the download made available from Roseindia is not exactly the same thing they present at the web site itself, the download has more code in one or another file, but it still does not work for me.

Error Messages:

Example #1:
----------------

http://localhost:8085/JSFTutorials/faces/welcomeJSF.jsp

HTTP Status 500 -

type Exception report

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.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:426)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

----------------
Example #2:
----------------


- Attempt without using Netbeans:

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: Servlet execution threw an exception
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: Servlet execution threw an exception
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:426)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:426)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


- Attempt using Netbeans:

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: Servlet execution threw an exception
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:491)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

javax.servlet.ServletException: Servlet execution threw an exception
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:426)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
java.lang.ClassLoader.loadClass(ClassLoader.java:247)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:426)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:115)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:706)
org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:677)
org.apache.jsp.index_jsp._jspService(index_jsp.java:57)
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:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

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

My relationship with Java has been like this for quite some time, and I want to change this.

Now the question: does anyone have any clue on what's wrong so that I can fix it? I've been a couple of hours into it unsuccessfully, the Roseindia web site made a wonderful job in explaining the underpinnings of JSF, that was so great for me, but how to make my code work? Any tips?

These are my files:

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

</web-app>

------------
------------
------------
faces-config.xml
------------

<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="1.2"
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">

<managed-bean>
<managed-bean-name>StoreNameBean</managed-bean-name>
<managed-bean-class>marcos.PersonBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<navigation-rule>
<from-view-id>/pages/inputname.jsp</from-view-id>
<navigation-case>
<from-outcome>result</from-outcome>
<to-view-id>result.jsp</to-view-id>
</navigation-case>
</navigation-rule>

</faces-config>

------------
------------
------------
Managed bean PersonBean.java
------------

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package marcos;

/**
*
* @author marcos.silvestri
*/
public class PersonBean {

String personName;

public String getPersonName() {
return personName;
}

public void setPersonName(String name) {
personName = name;
}
}

------------
------------
------------
index.jsp
------------

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:forward page="/pages/inputname.jsp" />
</body>
</html>

------------
------------
------------
inputname.jsp
------------
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle basename="roseindia.messages" var="message"/>

<!DOCTYPE html>
<f:view>
<html>
<head><title>enter your name page</title></head>

<body>
<h:form>
<h1><hutputText value="#{message.inputname_header}"/></h1>
<hutputText value="#{message.prompt}"/>
<h:inputText value="#{StoreNameBean.personName}" />
<h:commandButton action="result" value="#{message.button_text}" />
</h:form>
</body>
</html>
</f:view>

------------
------------
------------
result.jsp
------------

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle basename="marcos.messages" var="message"/>
<!DOCTYPE html>
<html>
<head><title>greeting page</title></head>
<body>
<f:view>
<h3><hutputText value="Hi,#{StoreNameBean.personName}!" />
<br/><hutputText value="#{message.greeting_text}" /></h3>
</f:view>
</body>
</html>

------------
------------
------------
messages.properties
------------

inputname_header=Roseindia JSF Tutorial
prompt=Enter Your Name:
greeting_text=Welcome In Roseindia JSF Tutorial
button_text=Submit

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

Trivial tutorials do not work, even when followed step-by-step.

I also tried to alter my pages to *.jsf instead of *.jsp, setting it according in web.xml, but no success at all.

Any clues?

Thanks in advance folks!


DJ aspirant, Engineering undergraduate, Tokusatsus addicted, fond of English language and Asia's, Buddhist, blogger, etc. I'll need to insert all these attributes in a Java class and manage to create methods for handling my overwhelming life
Ted Smyth
Ranch Hand

Joined: May 28, 2008
Posts: 73
The problem is you're following RoseIndia's tutorials. AVOID THEM AT ALL COST. OK - they're not all bad, but the vast majority of their tutorials are garbage, nonsense, or use bad/outdated java practices.

Try mkyong's http://www.mkyong.com/jsf2/ tutorials first.


Edward Smith
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
As a general comment, the error message you are getting: java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config

That seems to be referring to a JSTL class, which is not part of J2EE or JSF.
Adding the JSTL library to your project might resolve that issue.

Check out http://www.coderanch.com/how-to/java/JstlTagLibDefinitions for download links
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Welcome to the JavaRanch, Marcos!

As was mentioned, RoseIndia used to be a really good resource, but several years back, it took a real dive in quality and now it's pretty much useless.

If I'm not mistaken, the JSTL jar is required to run JSF (on many systems, anyway), despite the fact that you shouldn't actually code JSTL on JSF View definitions.


Customer surveys are for companies who didn't pay proper attention to begin with.
Marcos Silvestri
Ranch Hand

Joined: Dec 06, 2009
Posts: 62

Hello guys,

Sorry for the late response, it was the independence day here in Brazil yesterday and I was off duty.

By the way, thanks for the warm welcome and the useful information about Roseindia. It's impressive to know that most of my Google searches point out something at their web site, and then I find out that for quite some time their web site has been useless. Thanks for the info!

Regarding my problem, my co-worker managed to bring up and running a skeleton project from which I can proceed with my main objectives, the <rich:fileUpload> test and later implementation.

Let's see whether or not I'll struglle with that again, when attempting to create my own JSF applications.

Thanks again and cheers from Brazil!

Marcos
 
 
subject: Frustranting inability to run the most basic JSF application