The BalusC Code - JSF Tutori..
The BalusC Code - JSF Tutori..
Introduction
In this tutorial you will learn how to setup a Sun JSF RI 1.2 (Mojarra) playground with
Eclipse 3.4 (Ganymede) and Apache Tomcat 6.0 (Catalina). A JSF 1.2 environment
requires at least the Java 5.0, JSP 2.1 and Servlet 2.5 API's. We'll download and install
Java SE 6 SDK, Eclipse 3.4 IDE (with WTP for Java EE development) and Tomcat 6.0
Application server (which supports JSP 2.1 and Servlet 2.5 API's). Additionally we'll
also download and install JSTL 1.2 which can be used in combination with JSF, thanks
to unified EL.
There are also another IDE's available next to Eclipse, e.g. Sun Netbeans, Sun Java
Studio Creator, Oracle JDeveloper, IntelliJ IDEA, etcetera. The choice for Eclipse is
made because it's highly configureable, customizeable, has lots of helpful wizards and ..
it's free! True, it may eat memory and it may sometimes crash. Just make sure that your
environment has enough RAM memory for Java EE development. I recommend at least
2GB of which 1GB is reserved to Eclipse. Also at least a Pentium4 CPU around 3GHz,
or a Core 2 Duo CPU around 2GHz, or a Athlon64 CPU around 2.5GHz is
recommended. Also make sure that you install trusted plugins the right and clean way,
because the well-known Eclipse-instability is almost always caused by bad plugins.
There are also another application servers available next to Apache Tomcat, e.g. Sun
Java Application Server (also known as Glassfish in its current release), JBoss
Application Server, Mortybay Jetty, Objectweb Jonas, etcetera. The choice for Tomcat
is made because it's small, lightweight, relatively fast and is supported by Eclipse by
default by an excellent plugin. The only disadvantage of Tomcat is that it doesn't
support EJB's. So if you ever want to develop with EJB's, then you'll have to switch to
another application server which supports EJB's, such as Glassfish and JBoss AS.
Back to top
Preparing
Create a working directory where you install and store all related files. In this tutorial
we'll use C:\Java as working directory. If you want to store it somewhere else, then
you'll have to replace every occurence of "C:\Java" throughout the tutorial by the
desired directory.
Back to top
The Java SE 6 JDK contains the standard Java API. You can also consider to download
and install the Java EE 5 SDK instead which contains the Sun implementation of the
enterprise Java API next to the standard Java API. But the Java EE 5 SDK ships with a
Glassfish Application Server implementation, while we need the Tomcat Application
Server implementation. The Tomcat Application Server implementation already
contains at least the javax.el and javax.servlet implementations of the Java EE 5 API,
which are required by JSF. The javax.servlet.jsp.jstl implementation, which is also
required by JSF, is missing in the Tomcat implementation, but it can be downloaded
and installed separately. So we can just skip the download and installation of Java EE 5
SDK, the Java SE 6 JDK is sufficient.
Back to top
The Eclipse IDE is available in several tastes. As we're going to develop Java EE web
applications with JSF, we need the Java EE variant. It contains under each the WTP
(Web Tools Platform) which eases the development of web applications. The currently
latest version is Eclipse 3.4.
Back to top
The servlet-api.jar of Tomcat doesn't contain the JSTL API, while it is also required by
JSF. So we need to download it separately and place it in the classpath of Tomcat.
NOTE: if you don't have full control over Tomcat (e.g. production server or shared
hosting server), then you should rather put the jstl-1.2.jar in the /WEB-INF/lib of your
web project.
Back to top
Since the 1.2_07 release of Sun JSF RI, the Sun JSF RI project got a codename called
"Mojarra". You can find the project home page at http://javaserverfaces.dev.java.net.
Back to top
Run and configure Eclipse
2. On the welcome screen, click at the icon with the curved arrow at the right side:
Go to the workbench.
3. In the top menu, go to Window » Preferences » Java » Installed JREs. Select the
current JRE (it should automatically be the same as you have installed, in this
case the jre1.6.0_07, located at C:\Java\jre1.6.0_07) and click Edit. Select the
C:\Java\jre1.6.0_07\lib\rt.jar, click at Source Attachment, click at External File,
navigate to C:\Java\jdk1.6.0_07, select the src.zip file and add it. Now the source
code of the Java SE API is available in Eclipse.
24. Here are some more screenshots of how I configured some other preferences
(Text Editors, HTML Editor and Errors/Warnings):
Back to top
1. At the bottom box click at the Servers tab. Rightclick at the box and choose New
» Server. In the wizard, select the server type Apache » Tomcat v6.0 Server and
click Next. In the next page, click at Browse, point to C:\Java\apache-tomcat-
6.0.18 and click Finish. Now Tomcat is integrated in Eclipse.
2. Doubleclick the Tomcat server entry in the Servers tab, you'll get the server
configuration. At the left column, under Server Locations, select Use Tomcat
installation. This way Eclipse will take full control over Tomcat, so that you will
be able to access the default Tomcat homepage with the Tomcat Manager at
http://localhost:8080 when running from inside Eclipse. Optionally also check
Publish module contexts to separate XML files under Server options. Otherwise
Eclipse will modify the Tomcat's server.xml to its own taste, which may cause a
XML validation warning with
"[SetPropertiesRule]{Server/Service/Engine/Host/Context}" during Tomcat
startup (which actually doesn't harm at all). At the right column, under Ports,
please note the HTTP/1.1 port. This defaults to 8080, keep it in mind. You can
change it there if you want.
3. At the left column, under General Information, click Open launch configuration,
navigate to tab Arguments, in the field VM arguments add the following
argument at the end (separated with a space):
-Dorg.apache.el.parser.COERCE_TO_ZERO=false
4. Rightclick the Tomcat server entry in the Servers tab and choose Start. You can
also start it by clicking at the green arrow at the toolbar of the box. If you're
running a firewall, you'll probably get kind of a warning during the first time of
Tomcat startup. Just accept/allow/unblock it.
Back to top
1. At the left box open the Project Explorer tab if not already opened. Rightclick at
the box and choose New » Dynamic Web Project.
2. In the wizard, give it the Project name Playground, verify if Target Runtime is
set to Apache Tomcat v6.0 and Dynamic Web Module version is set to 2.5.
Under Configuration select JavaServer Faces v1.2 project and click Next.
3. In the next page, you may change the module settings to your taste. Personally I
like to have URL's always in lowercase, so I change the default Context Root
from Playground to playground. Click Next.
4. In the next page, you need to define JSF Capabilities. At JSF Libraries, select
Mojarra 1.2_09 <Default> (which we have definied in the preferences). At URL
Mapping Patterns, select the default /faces/* and remove it. Then add a new
pattern with the value *.jsf. Finally click Finish.
5. During the creation of the web project you'll probably get a license agreement
popup for the facesconfig_1_2.xsd file from sun.com. If you don't have any
intentions to do bad things, just click at I Agree.
6. After creation of the web project, you should get a directory structure similar to
Back to top
2. Enter the package name mypackage, enter the class name MyBean, keep the
other fields default and click Finish. The package and the class will be created
and the editor box will show the class source.
8. Add getters and setters: the input property will be used by an UIInput
component, so it require both a getter and a setter. The output property will be
used by an UIOutput component, so it require at least a getter. The setter is
optional, but it won't be used by the JSF component. Rightclick somewhere at
one of the both properties inside the source editor, choose Source » Generate
Getters and Setters, or hit ALT+SHIFT+S, then R. In the wizard, select the
desired getters and setters, if necessary choose the insertion point (I like to have
getters and setters at the whole bottom of the class) and the sorting (I like to
have getters first and then setters) and then click at OK. Eclipse will generate the
suitable getters and setters. Useful if you ever would have a lot of properties. If
necessary, hit CTRL+SHIFT+F to format the code again so that methods get
separated by a blank line. You can configure formatting preferences in Window
» Preferences » Java » Code Style » Formatter.
15. Define the backing bean in the faces-config.xml: doubleclick the file
WebContent/WEB-INF/faces-config.xml to open the Faces Configuration
editor. Navigate to the ManagedBean tab, select the request scope and click
Add.
16. In the wizard, enter the qualified class name mypackage.MyBean or click
Browse and enter MyBean to get the matching items and select the
mypackage.MyBean. Click next and verify if the managed bean name is set to
myBean. Finally click at Finish.
17. Go to the Source tab to see the managed bean entry. If necessary, hit
CTRL+SHIFT+F to get the XML formatted. Save the faces-config.xml by
choosing File » Save in the top menu or by pressing CTRL+S.
Back to top
1. Create a JSF file: rightclick at WebContent folder of the Playground project and
choose New » JSP. Enter the File name test.jsp, click Next, select the template
New JavaServer Faces (JSF) Page (xhtml strict) (which we have definied in the
preferences) and click Finish.
2. Add a basic form to the body of the test.jsp:
3. <h:form>
4. <h:outputLabel for="input" value="Enter your name:" />
5. <h:inputText id="input" value="#{myBean.input}"
required="true" />
6. <h:commandButton value="submit" action="#{myBean.action}" />
7. <h:outputText value="#{myBean.output}" />
8. <h:messages />
</h:form>
Save the test.jsp by choosing File » Save in the top menu or by pressing
CTRL+S.
Back to top
1. Rightclick the Tomcat server entry in the Servers tab and choose Add and
Remove Projects. In the wizard, select the Playground project under Available
Projects and click Add to add it to Configured Projects. Click Finish.
2. Rightclick the Tomcat server entry in the Servers tab and choose Start. You can
also start it by clicking at the green arrow at the toolbar of the box.
3. Once it is started, go to http://localhost:8080/playground/test.jsf. Note the .jsf
extension, it will be covered by the FacesServlet mapping in the
WebContent/WEB-INF/web.xml. So this request will be passed through the
FacesServlet and the FacesServlet will map it to the default JSP extension,
which is .jsp. The FacesServlet will also create the FacesContext and pass the
specific request through the JSF lifecycle.
Back to top
And now?
This whole blog site contains lot of useful JSF material. You can find them in the
Articles section at the right column of this blog site. Copy'n'paste them, or, preferably,
type it over, and play, experiment and run it. The most popular and recommendable
articles are the following:
JSF specification (pick the 1st download link), it explains why JSF is there, how
it works and what it all provides.
JSF API documentation, it contains detailed javadocs of the JSF API classes, it
explains where the classes are for, how to use them and what all fields/methods
do.
JSF TLD documentation, it shows which JSF tags are all available, what they all
do and which attributes they supports.
Java EE tutorial, chapter 10 and on contains Sun's own JSF tutorial.
If you want to get a book, I highly recommend the JSF: The Complete
Reference, one of its authors, Ed Burns, is the lead of the JSF specification.
You may want to checkout Facelets as replacement of JSP as view technology for JSF
components. It offers much more advantages over JSP and is going to be included in the
upcoming JSF 2.0 as default view technology.
Finally you can check the Favorites section at the right column of this blog site for
more interesting links.
Back to top
Copyright - None of this article may be taken over without explicit authorisation.
104 comments:
pascal said...
Hey BalusC, you have wonderfull articles over there! please I am an autodidact
in JSF and I ve got a small a problem with the use of binding, whenever I use
binding property an error that looks like " javax.servlet.ServletException:
Component ID select" occurs! what could be the problem? please tell me, if you
wish to analyse my code send me please your e-mail at murindwaz@gmail.com.
I ve found you every where on sun forum, and your comments and responses
helped me very much. and from there I found your blog! thanks U very much.
You're getting a "Duplicate component ID" error? Check throughout your JSF
code if every component has an unique ID.
For future questions which are not related to the blog article, please make use of
the Sun JSF forum. I browse those forums almost every day :)
January 12, 2008 1:18 PM
Marian said...
Could you please make available a tarball containig the sources of the project? I
try to run it, following your indications, but I only get the following error:
Re-read the article. The project is called 'Playground' and the context root is
called 'playground'.
One problem is, when I double click on server tab, it shows that http1.1 port is
8080
But when I choose to run test.jsp on server with the option "Update context root
for Web module proce"
the browser uses "http://localhost:8055/proce/test.jsf"
and the error is: The requested resource (/proce/test.jsf) is not available.
can it be the problem, I can't change it to 8055, it says it is used by another
process.
entering "http://localhost:8080/proce/test.jsf" to the browser also doesn't work
BalusC, this is one of the most beautiful tutorials I've seen. You're English is
almost perfect, better than most of the folks I work with here in the states. What
I found most useful was the lead-in describing where to get needed jars and who
has what, namely not needing Java EE 5 Platform. Wish I read you before
downloading - I needed jsf 1.2...
Thanks,
Don
Very good tutorial about JSF. Thanks a lot for your sharing.
Very nice tutorial! It's been a pleasure to read it and execute it without any error
in just half an hour. Thanks a lot.
Hi BalusC, I searched for many hours to find a working tutorial about Eclipse,
Tomcat and JSF and all I found was your great and (more important)
WORKING tutorial. I just wanted to say thank you!!!!
Greetings Elwood
Hi BalusC!
Nice "from scratch" tutorial, thx. Maybe you could expand your example with
use of the palette like in the WTP Tutorial (available via the eclipse online help:
JavaServer Faces Tools Tutorial)?
But thx anyway!
Excellent article, I was having trouble with putting jsf 1.2, tomcat 6 and java 5
and ruined my weekend. Thank god, I found this just in time. :)
Yep, I agree!
April 30, 2008 7:01 PM
cristian said...
Hi BalusC,
i've read your article and it's very help me for my project
But i have a little trouble here.
When i running my project and i try open it in my browser, it doesn't open. there
is some error said "The requested resource (/try/coba1.jsf) is not available". i
write http://localhost:8080/try/coba1.jsf in the url. could you tell me what
causing it? thank's before
This is just the same as a '404 page not found' error. So the URL is wrong or the
resource actually doesn't exist. So either the context root name is wrong, or the
file name is wrong, or the FacesServlet mapping is wrong. Retry the tutorial
without any changes.
Hi BalusC
I was wondering if you'd ever tried JBoss's Seam Eclipse plugin and how it
compares to the one in your tutorial?
Regards, Jeremy
Nice article BalusC. I've got a quick related question - Have you ever found
anything that formats your JSF pages well in Eclipse? Most of the plugins seem
to be able to format plain HTML well but when it comes to your JSF tags
(<h:commandLink> and the like) it seems to treat them as normal text and
doesn't indent them.
@Lee Theobald: Eclipse with WTP plugin formats JSF pages (in fact, JSP
pages) well. The WTP plugin is by default installed in the Eclipse Java EE
version.
Hi Balusc sir,
Thanks a lot for all your efforts for this tutorial.
As Lee Theobald said, I'm also not able to format JSF code using WTP all
version of Eclipse europa. It doesn't indent JSF tags. I tried all source
(HTML,CSS)configurations in eclipse but nothing worked. Please let me know
if some configuration is available or suggest if any plugin exists for this.
Thanks
BoyLukky
I can't reproduce your problem. It works fine here with Eclipse Java EE.
Hi Balusc,
After a small analysis i think i found a testcase.
JSF page without html tags ex: table,tr,td etc is being formatted nicely. But if we
use html tags then it's not being formatted by eclipse properly. I'm getting
h:datatable tag just after td in the same line after formatting, ideally which
should be in next line with indentation.
Please correct me if I'm wrong.
Thanks
BoyLukky
I see. I would try reporting this issue to the Eclipse boys here:
http://bugs.eclipse.org.
Great tutorial. Got it straight to the end withoug problems! Or almost,I had to
remove the "%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%" line
because I got an error on it. Have to check why (jstl-1.2.jar in tomcat\lib
though=. Any ideas ?
The reason of having problems with the jstl taglib in the proposed template is
that the JSTL library was not registred. It should be done after point 4 of the
"Run and configure Eclipse" section.
Method must have signature "String method()" but has signature "void
method()"
Thanks a lot!
This is not an error, it is just a warning. You can either ignore it (it will just run)
or replace void by String and return null. I just prefer void over returning null.
Thanks, BalusC.
but when I
http://localhost:8080/Playground/test.jsf
message /Playground/test.jsf
I didn't find any logs in the file system. I read all the other posts and some
people have the same issue. I checked everything carefully, but have not found
any solution.
First of all, the context root name in the tutorial is called 'playground'. If you left
yours unchanged, then you might not have added the project to Tomcat, or not
have mapped the FacesServlet on *.jsf correctly, or given the test.jsp another
name.
If you still fails in solving this, then I recommend to start over and do not try to
do something else than what the tutorial tells.
Hello again,
I tried your tutorial with success. Then wanted to add Hibernate to my project
(using Hibernate Synchronizer in Eclipse).
When I try to run my jsf page, I run into a problem with the
"HybernateException" class:
java.lang.ClassNotFoundException: net.sf.hibernate.HibernateException
I did all I could to put the Hibernate library in the correct place but the system
does not seem to find it.
I will rewrite this tutorial for Eclipse Ganymede sooner or later. Thank you.
Hello
I wonder how do I get started when the application type http://localhost:8080/
and not this way: http://localhost:8080/myApplication.
Thank you.
Note: I do not speak English, so we used a tool of translation. Excuse me if the
text is bad writing.
Thank you very much for this wonderful tutorial. You saved a lot of my time
and my setup is perfect now.
i have followed all the stpes but i am getting HTTP Status 404.
only difference in tour configuraion and my is below
Web Module version is set to 2.5(i have 2.4). Under Configuration select
JavaServer Faces v1.2(i have v1.1). on start up of tomcat there is also one
eexception java.lang.NoClassDefFoundError: javax/el/CompositeELResolver.
Still i am ale to see tomcat screen but not the application
The mentioned class is part of Servlet 2.5 / JSP 2.1. Are you using a Servlet 2.5 /
JSP 2.1 application server? E.g. Tomcat 6.x or newer.
Thanks BalusC,
now it is working fine.i was using older versions.
i am trying simple app with name and age on jsp with add button.
i have defined input fields value like this ..
value="#employeeAction.employee.name}",
but somehow i am getting Target Unreachable, 'employee' returned null
exception.sorry about deleting my previous post.
September 20, 2008 10:49 AM
subhi said...
Hi balusC,
Thanks for sharing your knowledge. You this tutorial help me a lot. I had
worked on jsf 1.5 ys back , it was hard to recall jsf config for me but your
tutorial help me a lot.
Thanks again.
Subhash.
Thank you so much! I've had tons of problems with getting this thing to work,
and you really saved my day :)
You can just ignore this. This is new since Tomcat 6.0.16.
Eclipse WTP adds a new attribute 'source' to the project related <context>
element in the server.xml of Tomcat which identifies the source of the context
(the actual project in the workspace which has this server definied).
Since Tomcat 6.0.16 any 'unexpected' XML tags and attributes in the server.xml
will produce a warning during the startup, although there is no DTD.
Hi BALUSC,
Many thanks for your time and effort. Keep going and post more useful tutorials.
Hi,
i'm Having a problem in your tut ,i did exactly as what you say and at the end
when i typed in the browser
http://localhost:8080/playground/test.jsp and the error is
HTTP Status 404 - /playground/test.jsp
message /playground/test.jsp
Thanks in Advance
Malick
very good tutorial, but its better to include richface, facelet and tomahawk
configuration in eclipse too...
That goes beyond the scope of this tutorial ;) I however agree that Facelets and
Tomahawk are worth inclucing in your web project. So is Ajax4jsf, which is just
part of RichFaces.
October 24, 2008 7:14 AM
tariqahsan said...
message /playground/test.jsp
What I found that in the WEB-INF/web.xml file I had this (had to take out the
tag as the it was complaining from blog posting) -
servlet-mapping
servlet-name>Faces Servlet servlet-name url-pattern .jsf url-pattern
servlet-mapping
This is indeed the most comprehensive every step of the way type JSF sample
tutorial I have seen so far. Great Job BalusC! Please continue to give us more of
this kind of tutorial.
Hi BalusC, thanks for the really helpful tutorial. Keep up the good work!!!
I want to ask you about different encodings than just plain English. I use Greek
and even if i changed Window-Preferences-Web-JSP Pages-Encoding to utf8 or
greek, i 'm still getting invalid characters on the screen.
I followed the tutorial and completed the setup with sample program. When I
started the Server by right click on the server I received the error message
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet:
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@4a65e0
javax.faces.webapp.FacesServlet
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
: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:*.jsf:/url-pattern:
:/servlet-mapping:"
The JSF libraries are missing in the classpath. Redo the tutorial from "Run and
configure Eclipse" on and verify if you did every step correct and didn't miss a
step.
I fixed the previous error. Now I received the below error in red color while
running a server after added playground project.
Hi I resolved the above issue. Typo error in url, typed test.jsp instead of giving
.jsf in the url.
Thanks ya.
A good approach and very useful for newbies.
Please put more & more examples and reusable components like tree +
datatable.
One more clarification, in a single jsf page, how to call multiple jsf pages. (For
example i divided the page into three part. First part having one jsf page, and
second part having another jsf page and third part having another jsf page.
There's already a datatable article at this blog. For including JSF pages use
jsp:include and f:subview. If you want to do this dynamically, there's another
article about that at this blog.
November 9, 2008 4:51 PM
jun said...
This best tutorial in this topic. Only problem I have is the same one Chris
mentioned:
-----
Great tutorial. Got it straight to the end withoug problems! Or almost,I had to
remove the "%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%" line
because I got an error on it. Have to check why (jstl-1.2.jar in tomcat\lib
though=. Any ideas ?
Hai BalusC,
Thanks a lot for posting such a useful material..
I was struggling hard to program in JSF but after seeing this i configured and
tried..
Its working ...again Thanks for helping people like me
SIVA.L
THANK YOU!!! these by far the best tutorial I've encountered this year. Every
thing was explained to details, its meaning and intentions. everything was
accurate.
However, I had to copy the jars from Mojarra to the TOMCAT/lib folder. That
solved it for me.
Thanks again
Hi,
That's a good Tutorial for a learner like me,i did exactly as you told and i can
run the project in inside eclipse browser,but the problem appears when i run it in
separate Browser(FF) and the error is
HTTP Status 500 -
exception
root cause
note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.18 logs.
Help me what to do
You need to pass the request through the FacesServlet. Also see point 3 of "Run
JSF web project in Tomcat".
Not. You need to pass the request through the FacesServlet anyway.
If your problem is rather that you don't want that the user can access JSP files
directly without passing it through the FacesServlet, then add the following
entry to the web.xml.
<security-constraint>
<display-name>Restrict direct access to JSP</display-name>
<web-resource-collection>
<web-resource-name>JSP</web-resource-name>
<url-pattern>*.jsp</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
Hi,
Thanks
It works
Nice tutorial for a newbie. Would you please extend this to be full fledged
tutorial on JSF.
Can we add the JSTL libraries also in the step # 4 under Run and configure
section eclipse instead of in Step #4 under Download and Install JSTL 1.2
(moving the jstl-1.2.jar section under C:\Java\apache-tomcat-6.0.18\lib
directory)?
Thanks mate, perfect read when taking first steps into the world that is JSF :)
Hi,This is a good tutorial. Just a suggestion, it will be good if you can add some
information about running tomcat inbuilt sample applications.
I did follow all ur instructions. The only problem is, I am not able to run any
sample application if I have started the server from eclipse. Sample application
works fine if I will start the server from outside.
Kishor
On section:
"Prepare JSF web project in Eclipse"
step 6: my directory structure doesn't look like the one in your picture, infact I
don't have the folder "Java Resources:src" with the 5 things in it, but a simple
src folder with nothing in it. So i can't go further with the example...i am
followed all of the steps before, do you have any idea of what could be the
problem?
Thanks a lot.
Are you in the "Project Explorer" view of the "Java EE" perspective? Sounds
like that you´re in the "Navigator" view or probably in the "Java" perspective.
oh ok i found it :)
Ok, i followed the entire procedure. The only problem that keeps me from
execute successfully the example is this:
at the point described in the part "Create JSF hello world in Eclipse - The JSF
file" step 2, in the code of the file test.jsp i have an error in the third row. it says:
Multiple annotations found at this line:
- Tag (jsp:directive.taglib) should be an empty-element tag.
- Cannot find the tag library descriptor for "http://java.sun.com/jsp/
jstl/core"
I tried to continue anyway and execute the rest, but as i try to open the url:
http://localhost:8080/playground/test.jsf i get the page with this error:
HTTP Status 500 -
message
exception
root cause
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHa
ndlerImpl.java:457)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java
:141)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.ja
va:109)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
root cause
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.j
ava:1387)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.j
ava:1233)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHa
ndlerImpl.java:457)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java
:141)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.ja
va:109)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.18 logs.
Make sure that you read and follow every step carefully.
Hey BalusC,
All of your articles are really helpful. Would you please publish a tutorial on JSF
and tiles?
Thanks
Thanks again.
Hi,
Thanks a lot for all your efforts for this tutorial. I could run the application
server(apache tomcat 6.0.18)also.(Configurations;apache tomcat 6.0.18,eclipse
SDK 3.4.1,mojarra 1.2_10)and I added richfaces-api,richfaces-impl,richfaces-ui
under WEB-INF/lib .
I see an error when I try to run my JSF project :
Thanks BalusC, your article helps me a lot. I'm new to JSF. Good job man.
Hi BalusC,
My problem: I use Eclipse 3.4.2 with tomcat 6.0 (n this combination even for
some other projects, but without JSF).
Follwoing your article, chapter "Prepare JSF web project in Eclipse", I click
"Finish" to create the project.
This results in an error message: "Failed while installing Dynamic Web Module
2.5". Reason: (the same). Details: NullPointerException.
After confirming this message, the created project is incomplete (just src, JRE
system libs, and build). View "problems" shows a new entry: "This project
needs to migrate WTP metadata".
Any idea?
Thanks a lot
Mark
This part of your code where I'm running the test.jsp program for the first time
--------------------------------------------------------------------------------
message
exception
TY ;)
Am using tomcat 5.5.23 and JSF 1.1 and Icefaces 1.7.2 in my project.
BalusC, you rock! This is the first JSF tutorial that I've gotten to work.....thanks
a lot!!!!!
Hi!
First everything was working fine and then I started playing around. All of a
sudden the following error occured.
message
exception
root cause
org.apache.jasper.el.JspPropertyNotFoundException: /test.jsp(16,8)
'#{myBean.input}' Property 'input' not readable on type java.lang.String
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:104
)
javax.faces.component.UIOutput.getValue(UIOutput.java:184)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBas
icInputRenderer.java:201)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlB
asicRenderer.java:284)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicR
enderer.java:154)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:
861)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:937)
javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.j
ava:837)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.j
ava:266)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java
:197)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.ja
va:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.18 logs.
Great tutorial.
I started out using the introduction in JSF: The Complete Reference. There they
build the jsf app on the command line and run it directly in tomcat. What about
all the commons-*.jar libraries ? are they included in the eclipse WTP
somewhere ?
Remco
Since Mojarra 1.2_05 there's no need for the commons libraries. Besides, most
of them are already included in the Tomcat library.
But,
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
property 'source' to 'org.eclipse.jst.jee.server:Playground' did not find a matching
property.
Balus,
I'm adding my thanks. Also, I was getting exceptions thrown by Tomcat when it
was started. I had to copy all the MyFaces (which I'm using instead of Mojarra)
jars into the tomcat/lib dir to solve the problem.
FYI, your tutorial also works using the MyFaces implementation. One just uses
the MyFaces jars instead of the Mojarra jars.
Thanks again!
Hey man, i am here to congratulate you, this is a wonderfull tutorial and the only
one I could complete successfully...you did a GREAT job, keep like that! ;)
Take Care
I have a little problem with JSF and tomcat. Sometimes the server just crash
when I execute some action on the JSF application. Inside the tomcat logs the
only usefull line that I find is:
Current CompileTask:
com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flushAttributes()
Post a Comment
About
BalusC
A deaf web application specialist who is currently employing for a company in
Curaçao. Having B.Sc. degree in Biomedical Science since may 2000. A
computer programming autodidact who started with C64 Simons Basic around
1989. Also a hardware geek since august 1996. Having Java experiences since
april 2003. Born in The Netherlands at march 1978 and living in Curaçao since
march 2008. Married with two children. Having two dog breed opposites, a
Golden Retriever and a Rhodesian Ridgeback.
View my complete profile
Tags
Ajax
Communication
Converter
CSV
DAO
DataTable
Download File
DTO
Dutch
Eclipse
Filter
Focus
Friendly URL
Highlight
Immediate
Include
JavaScript
JDBC
JSF
JSP
Managed Bean
PhaseListener
POST-Redirect-GET
Rant
Renderer
SelectBooleanCheckbox
SelectOneMenu
Servlet
TabbedPanel
Tomahawk
Tomcat
Tutorial
Unicode
Upload File
UseBean
Utility
Validator
ValueChangeListener
Whitespace
Ajax (1)
Communication (2)
Converter (3)
CSV (1)
DAO (4)
DataTable (2)
Download File (3)
DTO (7)
Dutch (7)
Eclipse (3)
Filter (5)
Focus (3)
Friendly URL (1)
Highlight (3)
Immediate (2)
Include (2)
JavaScript (6)
JDBC (3)
JSF (26)
JSP (7)
Managed Bean (12)
PhaseListener (5)
POST-Redirect-GET (3)
Rant (2)
Renderer (1)
SelectBooleanCheckbox (1)
SelectOneMenu (3)
Servlet (7)
TabbedPanel (1)
Tomahawk (2)
Tomcat (2)
Tutorial (6)
Unicode (1)
Upload File (3)
UseBean (1)
Utility (7)
Validator (5)
ValueChangeListener (2)
Whitespace (1)
Articles
▼ 3000 (1)
o ▼ January (1)
Welcome
► 2009 (3)
o ► May (2)
Java/JSP/JSF and JavaScript
Unicode - How to get the characters right?
o ► February (1)
FileServlet supporting resume and caching and GZIP...
► 2008 (9)
o ► October (1)
Effective datatable paging and sorting
o ► September (1)
Validate required checkbox
o ► August (1)
Styling options in h:selectOneMenu
o ► July (3)
DAO tutorial - use in JSF
DAO tutorial - use in JSP/Servlet
DAO tutorial - the data layer
o ► June (1)
What is it with roseindia?
o ► February (1)
Uploading files with JSF
o ► January (1)
JSF tutorial with Eclipse and Tomcat
► 2007 (20)
o ► December (4)
Action dependent requireness
Set focus and highlight in JSF
Validator for multiple fields
WhitespaceFilter
o ► November (2)
Friendly URL's in JSF
MultipartFilter
o ► October (1)
Populate child menu's
o ► September (4)
DateUtil
CalendarUtil
FileUtil
Objects in h:selectOneMenu
o ► August (1)
Generic object converter
o ► July (1)
FileServlet
o ► April (1)
ImageServlet
o ► March (4)
User session filter
Facade POST by GET
POST-Redirect-GET pattern
JDBC tutorial (Dutch)
o ► January (2)
Generics (Dutch)
Dynamic JSF subviews
► 2006 (25)
o ► October (2)
StringUtil
MathUtil
o ► September (1)
Debug JSF lifecycle
o ► June (8)
Bestandsbewerkingen (Dutch)
Parse CSV upload
Using datatables
Collecties en mappen (Dutch)
Data conversies (Dutch)
DB2 LOWER() bug
Datum en tijd (Dutch)
Communication in JSF
o ► May (3)
HttpServletUtil
PDF handling
Restore tabbedpanel
o ► April (11)
Java tutorial (all Dutch)
Java tutorial - Basics
Java tutorial - Elementen
Favorites
Use the right keywords
How to write good code
How to write bad code
Java SE 6.0 API documentation
Java EE 5.0 API documentation
Servlet home page
Servlet 2.5 specification (JSR154)
Servlet 2.5 API documentation
JSP home page
JSP 2.1 specification (JSR245)
JSP 2.1 API documentation
JSP 2.1 / JSF 1.2 EL API documentation
JSTL home page
JSTL 1.2 specification (JSR052)
JSTL 1.1 TLD documentation (1.2 isn't avail??)
JSF home page
JSF 1.2 specification (JSR252)
JSF 1.2 API documentation
JSF 1.2 TLD documentation
JSF tutorial (Java EE tutorial chpt 10 and on)
JSF tutorials overview
JSF tutorials (somewhat outdated but complete)
JSF custom components
JSF The Complete Reference (book)
Eclipse IDE for Java EE developers
Eclipse Web Tools Platform
Hibernate API Reference Documentation
Hibernate Tools Reference Guide
IBM DB2 SQL message reference
HTML Doctype explained
LinkedIn
Followers