Friday, January 4, 2008

JSF tutorial with Eclipse and Tomcat

WARNING - OUTDATED CONTENT!

There is a newer JSF 2.0 tutorial out with Eclipse 3.6 SR1 (Helios) and Glassfish v3.

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

Download and install Java SE 6 JDK

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.

  1. Surf to the Java SE 6 JDK download page.
  2. Pick the latest non-beta JDK without Java EE SDK and/or Netbeans, currently it is called JDK 6 Update 7. Press the Download button.
  3. Choose Platform/Language, accept the License Agreement and press the Continue button.
  4. Click at the link below 'Java SE Development Kit 6u7', you will get the file jdk-6u7-windows-i586-p.exe (naming may differ per version), save it to disk.
  5. Install the JDK and JRE in C:\Java\jdk1.6.0_07 and C:\Java\jre1.6.0_07 respectively.
Back to top

Download and install Eclipse 3.4 IDE

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.

  1. Surf to the Eclipse download page.
  2. Click at the Eclipse IDE for Java EE Developers link.
  3. Download or pick a mirror and you will get the file eclipse-jee-ganymede-win32.zip (naming may differ per version), save it to disk.
  4. Extract the zip and move the child directory \eclipse to C:\Java\eclipse.
Back to top

Download and install Tomcat 6.0

The Tomcat Application Server is available in several releases, each supporting a different JSP/Serlvet specification. As we're going to develop with JSF 1.2, we need at least the Tomcat release supporting JSP 2.1 and Servlet 2.5. However, if you're using another view technology than JSPs, such as Facelets or JSFTemplating, then you can run JSF 1.2 on JSP 2.0 and Servlet 2.4 without issues. This is supported by at least Tomcat 5.5.

  1. Surf to the Tomcat 6.0 download page.
  2. Scroll a bit down the page and under Binary Distributions » Core click at the zip link.
  3. You will get the file apache-tomcat-6.0.18.zip (naming may differ per version), save it to disk.
  4. Extract the zip and move the child directory \apache-tomcat-6.0.18 to C:\Java\apache-tomcat-6.0.18.
Back to top

Download and install JSTL 1.2

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.

  1. Surf to the JSTL 1.2 download page.
  2. Click at the jstl-1.2.jar link.
  3. You will get the file jstl-1.2.jar (naming may differ per version), save it to disk.
  4. Move it unchanged to the C:\Java\apache-tomcat-6.0.18\lib directory, which is the main 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

Download and install Mojarra 1.2

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.

  1. Surf to the Mojarra download page.
  2. Download the binary of the latest release, so click at the 1.2_09 binary link.
  3. You will get the file mojarra-1.2_09-b02-FCS-binary.zip (naming may differ per version), save it to disk.
  4. Extract the zip and move the child directory mojarra-1.2_09-b02-FCS to C:\Java\mojarra-1.2_09-b02-FCS.
Back to top

Run and configure Eclipse

  1. Run C:\Java\eclipse\eclipse.exe. You will be asked to select a workspace. Point it to C:\Java\workspace.
  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.
  4. In the Preferences dialogue, go to Web » JavaServer Faces Tools » Libraries and click New. Give the library an unique name, e.g. Mojarra 1.2_09. Set Version Supported to v1_2. Under Library Jars, click Add, navigate to C:\Java\mojarra-1.2_09-b02-FCS\lib, select the both JAR's jsf-api.jar and jsf-impl.jar and add them. Check Is JSF Implementation and click Finish.
    Note: since Eclipse 3.6, it has been moved into Java » Build Path » User Libraries. You should define it over there or just skip this step.
  5. In the Preferences dialogue, go to Web » JSP Files » Editor » Templates and click New. Enter name New JavaServer Faces (JSF) Page (HTML5), select context New JSP, enter description JSF with HTML5 markup and default view setup, copypaste the following snippet in the pattern field and click OK:
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    
    <!DOCTYPE html>
    
    <f:view>
        <html lang="en">
            <head>
                <title>Insert title here</title>
            </head>
            <body>
                ${cursor}
            </body>
        </html>
    </f:view>
  6. In the Prefrences dialogue, go to Web » JavaServer Faces Tools » Validation and under Type Assignment Problems set Method expression signature incompatibility to Warning or Ignore if you want to allow JSF action methods return void. I also recommend to set the Unary operation number (and boolean) coercion problems under Type Coercion Problems to Warning or Ignore, because it would unnecessarily give an error when you're using for example UIComponent#getValue() -which has Object type outcome- in EL but you treated it as number or boolean.
    I have filed a bug about this, vote for it if you agree!
  7. In the Preferences dialogue, go to General » Editors » Text Editors » Spelling and disable it. Really. It will save you from a big annoyment, because it also unnecessarily spellchecks XML documents like web.xml, faces-config.xml and on.
  8. Here are some more screenshots of how I configured some other preferences (Text Editors, HTML Editor and Errors/Warnings):
  9. Click OK to close the Preferences dialogue.
Back to top

Integrate Tomcat in Eclipse

  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

    This will fix an unwanted feature in the EL implementation which was introduced along with Tomcat 6.0.16 (empty number fields become 0 and so on). Also see this bug and the links in it. Click OK to close the launch configuration properties and save the configuration by choosing File » Save in the top menu or by pressing CTRL+S. Close the server configuration by clicking at the cross of the tab, or by pressing CTRL+F4.
  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.
  5. Once it is started, go to http://localhost:8080 (where 8080 is supposed to be the HTTP/1.1 port of Tomcat). You should get the default Tomcat home page.

    If you get a timeout or kind of an unknown host error message, then doublecheck if Tomcat is configured properly (you should have selected Use Tomcat installation in step 2 and use the right port number) and if it is started properly. In Eclipse you can find the Tomcat logs at the Console tab of the bottom dialogue box.
  6. You can stop the server by rightclicking at the Tomcat server entry in the Servers tab and choose Stop. You can also stop it by clicking at the red square at the toolbar of the box.
Back to top

Prepare JSF web project in Eclipse

  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.
    Note: since Eclipse 3.6, the library selection has been changed. You should select User Library or just Disable Library Configuration and supply the JAR files in /WEB-INF/lib yourself.
  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 the screenshot below.
Back to top

Create JSF hello world in Eclipse - The Backing Bean

  1. Create a backing bean class: open the Playground project, rightclick at Java Resources folder and choose New » Class.
  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.
  3. Add two properties to the bean:
    
        private String input;
        private String output;
     
    
  4. 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.
  5. Add an action method to the bean:
    
        public void action() {
            output = "Welcome at the JSF world, " + input;
        }
     
    
    Save the mypackage.MyBean by choosing File » Save in the top menu or by pressing CTRL+S.
  6. 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.
  7. 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.
  8. 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

Create JSF hello world in Eclipse - The JSF file

  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 (HTML5) (which we have definied in the preferences) and click Finish.
  2. Add a basic form to the body of the test.jsp:
    <h:form>
        <h:outputLabel for="input" value="Enter your name:" />
        <h:inputText id="input" value="#{myBean.input}" required="true" />
        <h:commandButton value="submit" action="#{myBean.action}" />
        <h:outputText value="#{myBean.output}" />
        <h:messages />
    </h:form>
    Save the test.jsp by choosing File » Save in the top menu or by pressing CTRL+S.
Back to top

Run JSF web project in Tomcat

  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.

    If you get a timeout or kind of an unknown host error message, then doublecheck if Tomcat is started properly and if the port is correct. If you get an internal server error exception, then doublecheck if the code is all correct. Also try to interpret and understand the exception message and the trace, if necessary with help of Google. In Eclipse you can find the Tomcat logs at the Console tab of the bottom dialogue box.
Back to top

And now?

Play with it!

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:

Here are the most important JSF related links to be bookmarked and read thoroughly:

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

(C) January 2008, BalusC

155 comments:

Pascal Maniraho 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.

Bauke Scholtz said...

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

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:

Jan 20, 2008 9:56:12 AM com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /test.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@ffd135]
Jan 20, 2008 9:56:12 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at com.sun.faces.mgbean.ManagedBeanBuilder.bakeBeanProperty(ManagedBeanBuilder.java:350)
at com.sun.faces.mgbean.ManagedBeanBuilder.bake(ManagedBeanBuilder.java:107)

Eren Aykin said...

I did everythind as said but I get the error:
"The requested resource (/Project/test.jsf) is not available."

Bauke Scholtz said...

Re-read the article. The project is called 'Playground' and the context root is called 'playground'.

Eren Aykin said...

And my project name is 'Proce' and context root is 'proce'

Errors in my console are like:
INFO: Initializing Sun's JavaServer Faces implementation (1.2_07-b03-FCS) for context '/proce'
java.lang.ClassCastException: com.sun.faces.lifecycle.LifecycleFactoryImpl cannot be cast to javax.faces.lifecycle.LifecycleFactory
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:1106)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:766)
...
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.GlassFishConfigureListener
java.lang.ClassCastException: com.sun.faces.application.ApplicationAssociate cannot be cast to com.sun.faces.application.ApplicationAssociate
at com.sun.faces.application.ApplicationAssociate.getInstance(ApplicationAssociate.java:208)
at com.sun.faces.config.JSFVersionTracker.publishInstanceToApplication(JSFVersionTracker.java:269)
...
SEVERE: Error listenerStart
03.Åžub.2008 15:43:52 org.apache.catalina.core.StandardContext start
SEVERE: Context [/proce] startup failed due to previous errors


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

I'm a newbie and trying to understand, sorry if this is a stupid problem.

Anonymous said...

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

Hats off to you!!

Thanks,
Don

Gene Shen said...

Very good tutorial about JSF. Thanks a lot for your sharing.

Unknown said...

I had been struggling with making my sample applications work for almost a week now.I had all sorts of issues - imcompatible versions, incorrect guidelines from vendors...
With your instructions, I got my sample working within a couple of hours.
Thanks for taking the time and for making the effort to share your knowledge with the community.
Regards
RJ

1nv3r53 said...

excellent tut balusc sir.
u r forum and tuts have helped me a lot in starting up with jsf.
thanks a lot.

Unknown said...

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.

andi said...

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

Carsten Strauss said...

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!

Chandoo said...

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. :)

Unknown said...

Yep, I agree!

Unknown 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

Bauke Scholtz said...

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.

gr8fanboy said...

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

Unknown said...

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.

Bauke Scholtz said...

@LookingForSpring: no, I haven't tried it out.

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

Unknown said...

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

Bauke Scholtz said...

I can't reproduce your problem. It works fine here with Eclipse Java EE.

Unknown said...

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

Bauke Scholtz said...

I see. I would try reporting this issue to the Eclipse boys here: http://bugs.eclipse.org.

chris said...

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 ?

chris said...

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.

Unknown said...

Hello BalusC,
Its a nice article and I was able to configure my environemnt as per your tutuorial.
I could run the demo application also.
I see an error when I try to run my JSF project -
SEVERE: Error configuring application listener of class com.sun.faces.config.ConfigureListener
java.lang.NoClassDefFoundError: com/sun/org/apache/commons/digester/RuleSet
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:3787)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Jul 15, 2008 10:53:07 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Jul 15, 2008 10:53:07 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 15, 2008 10:53:07 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/CMA_NEW] startup failed due to previous errors

I am unable to launch my applciation.Please help.

Bauke Scholtz said...

The Apache Commons Digester JAR is missing in the classpath.

hopebest said...

Hello BalusC,

I tried the tutorial, but I got error in test.jsp:

Method must have signature "String method()" but has signature "void method()"

at line (sorry HTML is not allowed for the post)
commandButton value="submit" action="#{myBean.action}"

How should I fix it?

Thanks a lot!

Bauke Scholtz said...

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.

hopebest said...

Thanks, BalusC.

but when I
http://localhost:8080/Playground/test.jsf

HTTP Status 404 - /Playground/test.jsf

type Status report

message /Playground/test.jsf

description The requested resource (/Playground/test.jsf) is not available.
Apache Tomcat/6.0.16

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.

Bauke Scholtz said...

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.

chris said...

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.

Where should I check first ?

Thanks for your help.

Bauke Scholtz said...

Add it to the classpath of the project. It covers at least the /WEB-INF/lib directory. It is recommended to put any 3rd party JAR's in there.

Bauke Scholtz said...

@Hopebest: today I installed Eclipse Ganymede and I discovered that you're right. This tutorial was based on Eclipse Europa and the error you're occurring wouldn't occur in it. I've added a new line to the tutorial:

# If you're using Eclipse Ganymede, under the Prefrences dialogue, go to Web » JavaServer Faces Tools » Validation and under Type Assignment Problems set Method expression signature incompatibility to Warning or Ignore if you want to allow JSF action methods return void.

I will rewrite this tutorial for Eclipse Ganymede sooner or later. Thank you.

Unknown said...

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.

Unknown said...

I could do deploy. The problem was an error that happened in a production environment, but not the case in the development environment.

a. said...

Thank you very much for this wonderful tutorial. You saved a lot of my time and my setup is perfect now.

I will read very often your blog.

Unknown said...

Thanks man for providing useful tutes on JSF...

Sunil said...

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

Bauke Scholtz said...

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.

Sunil said...

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.

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

Bauke Scholtz said...

@Sunny: make sure that employee is not null. E.g.

Employee employee = new Employee();

Sunil said...

thanks for replay,but i have declared employee as managed bean so it should be initialized automatically like employeeAction(which is also managed bean) as we dont call new on employeeAction directly. please suggest

SmaJLe said...

Thank you so much! I've had tons of problems with getting this thing to work, and you really saved my day :)

Now I can finally get back to the listening of the lesson...

Unknown said...

My test.jsf works, but I got the following: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Playground' did not find a matching property.

Is there a way to resolve this warning ?

Bauke Scholtz said...

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.

Just ignore it. Your web project is fine.

Hareesh Ram Chanchali said...

Hi BALUSC,

Many thanks for your time and effort. Keep going and post more useful tutorials.

Hareesh Ram Chanchali

this.malick said...

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

type Status report

message /playground/test.jsp

description The requested resource (/playground/test.jsp) is not available.

Tell me what i need to do

Thanks in Advance
Malick

Jonly said...

very good tutorial, but its better to include richface, facelet and tomahawk configuration in eclipse too...

Bauke Scholtz said...

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.

Tariq Ahsan said...

I was also getting the HTTP Status 404 - /playground/test.jsp

type Status report

message /playground/test.jsp

description The requested resource (/playground/test.jsp) is not available ...

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

On the console I was getting the error -
...
Caused by: java.lang.IllegalArgumentException: Invalid url-pattern .jsf in servlet mapping ...

To correct problem I changed
url-pattern *.jsf url-pattern
in the web.xml. (The '*' missing)
Build and bounced the Tomcat server and it worked.

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.

aris said...

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.

Pranayaa said...

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

Web.xml under WebContent folder has the following content:

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

Please help me to resolve this.

Bauke Scholtz said...

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.

Pranayaa said...

I fixed the previous error. Now I received the below error in red color while running a server after added playground project.

java.lang.RuntimeException: Cannot find FacesContext

ov 9, 2008 10:30:30 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Playground' did not find a matching property.
Nov 9, 2008 10:30:30 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java\jre1.5.0_01\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Nero\Lib\
Nov 9, 2008 10:30:31 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-80
Nov 9, 2008 10:30:31 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2359 ms
Nov 9, 2008 10:30:31 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Nov 9, 2008 10:30:31 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
Nov 9, 2008 10:30:33 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_10-b01-FCS) for context '/playground'
Nov 9, 2008 10:30:35 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.ContextListener" is already configured for this context. The duplicate definition has been ignored.
Nov 9, 2008 10:30:35 PM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "listeners.SessionListener" is already configured for this context. The duplicate definition has been ignored.
Nov 9, 2008 10:30:36 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Nov 9, 2008 10:30:36 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Nov 9, 2008 10:30:36 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.catalina.Registry', 'org.apache.tomcat.util.modeler.Registry@384065')
Nov 9, 2008 10:30:36 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.catalina.MBeanServer', 'com.sun.jmx.mbeanserver.JmxMBeanServer@10bbf9e')
Nov 9, 2008 10:30:36 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-80
Nov 9, 2008 10:30:37 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Nov 9, 2008 10:30:37 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/140 config=null
Nov 9, 2008 10:30:37 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5868 ms
Nov 9, 2008 10:31:42 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.RuntimeException: Cannot find FacesContext
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
at org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:105)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:82)
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:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
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.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
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:447)
at java.lang.Thread.run(Unknown Source)

Pranayaa said...

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.

Bauke Scholtz said...

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.

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

July 6, 2008 9:55 AM
chris said...
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.

Could chris or someone give more detail how to register JSTL

shiva said...

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

learncards said...

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

javafreak said...

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 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.RuntimeException: Cannot find FacesContext
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.RuntimeException: Cannot find FacesContext
javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
org.apache.jsp.test_jsp._jspx_meth_f_005fview_005f0(test_jsp.java:105)
org.apache.jsp.test_jsp._jspService(test_jsp.java:82)
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:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

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

Help me what to do

Bauke Scholtz said...

You need to pass the request through the FacesServlet. Also see point 3 of "Run JSF web project in Tomcat".

pjzajdel said...

How should I change the project to get the result without adding 'test.jsf' in a URL address. Best regards.

Bauke Scholtz said...

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>

javafreak said...

Hi,
Thanks
It works

blog4scs said...

Nice tutorial for a newbie. Would you please extend this to be full fledged tutorial on JSF.

blog4scs said...

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

Bauke Scholtz said...

You can, yes.

Bossie said...

This
Is
AWESOME!

Thanks mate, perfect read when taking first steps into the world that is JSF :)

Gupta said...

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

Bauke Scholtz said...

Are you able to access its manager homepage at http://localhost:8080 anyway? Maybe you missed step 2 of "Integrate Tomcat in Eclipse".

SmaJLe said...

THANK YOU !!!! It saved my day :)

eggy said...

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.

Bauke Scholtz said...

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.

tripleaxel said...

hi,
i'm stuck at the step 6 of the section "Create JSF hello world in Eclipse - The Backing Bean". The problem is, when i doubleclick the file WebContent/WEB-INF/faces-config.xml it doesn't open the Faces Config Editor but the actual xml file (the code)
...What is wrong?

tripleaxel said...

oh ok i found it :)

tripleaxel said...

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 -

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:457)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:141)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java: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.java:1387)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:457)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:141)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java: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.

instead of the result.

Can you help me? I'd be very grateful...thanks.

Bauke Scholtz said...

JSTL is missing in classpath.

Make sure that you read and follow every step carefully.

blog4scs said...

Hey BalusC,
All of your articles are really helpful. Would you please publish a tutorial on JSF and tiles?

Thanks

Anandhu said...

That was very great introduction... thanks balu

Bauke Scholtz said...

Carefully read step 4 of "Prepare JSF web project in Eclipse" chapter.

ringo said...

Thanks BalusC, your article helps me a lot. I'm new to JSF. Good job man.

mark said...

Hi BalusC,

really great work, thanks.

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

Unknown said...

This part of your code where I'm running the test.jsp program for the first time

I get this error from Tomcat
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: /test.jsp(15,37) #{..} is not allowed in template text
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:713)
org.apache.jasper.compiler.Node$ELExpression.accept(Node.java:940)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Validator.validate(Validator.java:1739)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java: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)

Unknown said...

TY ;)

It's a really nice job, BalusC, thanx man.

Unknown said...

Am using tomcat 5.5.23 and JSF 1.1 and Icefaces 1.7.2 in my project.

Consider the following code snipet :

ice:outputText value="#{fn:toLowerCase('Deepak')}" /ice:outputText When i tried to use jstl functions in jsp page, its working fine but when i tried it with jspx file(i.e., along with Icefaces), i got the following error.

SEVERE: No function is mapped to the name "fn:toLowerCase"
Mar 15, 2009 11:44:23 AM com.icesoft.faces.webapp.parser.Parser parse
SEVERE: Failed to execute JSP lifecycle.
javax.servlet.jsp.JspException: com.sun.faces.el.impl.ElException: No function is mapped to the name "fn:toLowerCase"
at com.icesoft.faces.component.OutputTextTag.doEndTag(OutputTextTag.java:398)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:240)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:223)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:223)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:223)
at com.icesoft.faces.webapp.parser.Parser.executeJspLifecycle(Parser.java:223)
at com.icesoft.faces.webapp.parser.Parser.parse(Parser.java:160)
at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:528)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:159)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
at com.icesoft.faces.context.View$2.respond(View.java:44)
at com.icesoft.faces.webapp.http.servlet.ServletRequestResponse.respondWith(ServletRequestResponse.java:167)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet$ThreadBlockingRequestResponse.respondWith(ThreadBlockingAdaptingServlet.java:36)
at com.icesoft.faces.context.View.servePage(View.java:274)
at com.icesoft.faces.webapp.http.core.SingleViewServer.service(SingleViewServer.java:52)
at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:38)
at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:55)
at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:91)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
at java.lang.Thread.run(Unknown Source)
Mar 15, 2009 11:44:23 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Persistent Faces Servlet threw exception

Unknown said...

BalusC, you rock! This is the first JSF tutorial that I've gotten to work.....thanks a lot!!!!!

Christian said...

Hi!

First everything was working fine and then I started playing around. All of a sudden the following error occured.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: /test.jsp(16,8) '#{myBean.input}' Property 'input' not readable on type java.lang.String
javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)


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(HtmlBasicInputRenderer.java:201)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:284)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.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.java:837)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java: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.

I would appreciate your help!

Reri42 said...

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

Bauke Scholtz said...

Since Mojarra 1.2_05 there's no need for the commons libraries. Besides, most of them are already included in the Tomcat library.

Unknown said...

Uitstekend! Me gusto mucho el tutorial!

Very well done.

To those having the error java.lang.AbstractMethodError: gnu.xml.dom.DomElement.getTextContent()Ljava/lang/String when starting Tomcat: clean your classpath! In my case, an old library called gnujaxp.jar caused the problem.

Cedric, from Nicaragua.

qwe said...

Wonderful article for starting with jsf!!!

But,
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Playground' did not find a matching property.

Why do i get this warning while trying to start Tomcat???

Bauke Scholtz said...

Check my reply at October 4, 2008 10:04 PM.

Roberto Melo Cavalcante said...

Balus,

This article is very well written. Congratulations!

It is very clear, very direct. Perfect!

Blogarhythm said...

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!

Artur said...

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! ;)

nilesh said...

Too good for a beginner...

Abdul Ahad said...

It was a greate article for newbeas to JSF. Nice job

keep it doing bro...

Take Care

Miguel D said...

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

Louis Lane said...

Thank you so much for this tutorial! I tried at least 6 different tutorials from scratch and none of them worked until yours! I'll be back frequently.

milian said...

Hi BalusC,

Thanks for this great article :)

Ramesh "Defeat the Defeats;Defeat defeats you" said...

Hi balusC,
I'm using
tomcat-5.5
eclipse Galileo
JSF 1.1
Am always getting this error...
please help me....
HTTP Status 404 - /Playground/test.jsp

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

type Status report

message /Playground/test.jsp

description The requested resource (/Playground/test.jsp) is not available.


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

Apache Tomcat/5.5.26

Bauke Scholtz said...

A 404 simply means that the URL is plain wrong. Make sure that the case is correct. It is case sensitive and the tutorial speaks about "playground" and not "Playground".

Another issue with the URL is that you aren't running the FacesServlet using *.jsf as mentioned in tutorial. If you continue so, you would get an RuntimeException: Cannot find FacesContext at end.

Kaumil Gandhi said...

Hi BalusC

This article is wonderful, everything ran successfully for me. :D

But your and for others better understanding, when going Preferences Window -> Web -> JavaServer Faces Tools their is nothing like Library but still we can Add two parameters (C:\Java\mojarra-1.2_09-b02-FCS\lib, select the both JAR's jsf-api.jar and jsf-impl.jar) while creating New Dynamic Web Project and hence both the things are same.

Once again thxs for your wonderful article.

regards,
Kumar

Ramesh "Defeat the Defeats;Defeat defeats you" said...
This comment has been removed by the author.
Bauke Scholtz said...

Follow Tutorial step by step. Do not change anything unless you understand what you're doing.

Ramesh "Defeat the Defeats;Defeat defeats you" said...

Hi,

still am getting the same error...

i ve done all the step but step 4 it is mentioned as Preferences Window -> Web -> JavaServer Faces Tools their is nothing like Library,so i just added those two .jar files in user libraries....
was it is right? or do i need any modification?
please urgent...

Ramesh "Defeat the Defeats;Defeat defeats you" said...

i have followed all the steps as given...i get this error


HTTP Status 404 - Servlet Faces Servlet is not available

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

type Status report

message Servlet Faces Servlet is not available

description The requested resource (Servlet Faces Servlet is not available) is not available.


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

Apache Tomcat/5.5.26


could u tell me what to do next

Jerry Debidien said...

Thanks for the tutorail!

Anupriya Srivastava said...

Hi, Excellent tutorial. I am facing one problem though... what listener to use in web.xml. I am getting following error:Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@119cca4
javax.faces.webapp.FacesServlet
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet.

The error is because there is no class loader: listener. i can use myfaces.StartupContextListener but then i am using mojara 1.2.09 lib.
Should i download my faces as well

Bauke Scholtz said...

Hi, you don't need one. Just follow the steps in the tutorial as-is and it should work.

HSc@n said...

Thanks for the tutorial. Realy amazing!

Unknown said...

Thanks for the help! This is an informative post!

Unknown said...

Hello BalusC,

I read in a post on Sun Forum where you wrote: "JSF 1.2 requires JSP 2.0 (implicitly: Servlet 2.4). It will only work well if you declare web.xml as at least Servlet 2.4. If you insist in keeping Servlet 2.3 for some reasons, consider replacing JSP by Facelets." This article says different. Sorry for my ignorance but I am confused. Can you please clarify? Sorry, I could not find the link to the post.

Thanks,
M

spand said...

Hi,

I have a Trinidad 1.2 application using MyFaces 1.2. From that application's backing bean I want to forward to this File Upload applcation. How can I do it?

Thanks,

Sonia

Gilton Nascimento said...

Thanks, I've learned a lot!

share said...

I spent a good time to follow your steps and it is working for me. Your instructions are much more accurate than the JSF book I got few days ago. Paid a big $$ for it.
please continue with using annotations instead of faces-config.xml.

thanks lot..:)

Shanmuganathan said...

Excellent tutorial. Its working for me. Thanks a lot BalusC

Unknown said...

Awesome article -- almost two years after it was written, it's still useful! Setting all this stuff up is confusing at best (especially coming from a MS Visual Studio background); this article really helped clear everything up.

Thanks!

Unknown said...

BalusC,

This blog is THE BEST for JSF. I have tried finding everything under one roof starting from configuring eclipse.

Thank you so much.

CYRIL said...

I was able to get the right result for first time .As I restarted my computer on next day,I got follwing strange error

exception

javax.servlet.ServletException: Unable to create managed bean myBean. The following problems were found:
- Bean or property class mypackage.MyBean for managed bean myBean cannot be found.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)


root cause

com.sun.faces.mgbean.ManagedBeanCreationException: Unable to create managed bean myBean. The following problems were found:
- Bean or property class mypackage.MyBean for managed bean myBean cannot be found.
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:204)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
org.apache.el.parser.AstValue.getValue(AstValue.java:107)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UIOutput.getValue(UIOutput.java:184)
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:287)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.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.java:837)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java: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)

Bauke Scholtz said...

The mentioned bean class is missing in classpath. Try clean/rebuild/redeploy.

CYRIL said...

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: viewId:/test2.jsf - View /test2.jsf could not be restored.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)


root cause

javax.faces.application.ViewExpiredException: viewId:/test2.jsf - View /test2.jsf could not be restored.
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:189)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:102)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

CYRIL said...

I was able to resolve that issue .But I am getting this issue at tme

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: viewId:/test2.jsf - View /test2.jsf could not be restored.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:270)


root cause

javax.faces.application.ViewExpiredException: viewId:/test2.jsf - View /test2.jsf could not be restored.
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:189)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:102)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

Bauke Scholtz said...

You need to refresh the GET request whenever you restart the server.

Jaya said...
This comment has been removed by the author.
Jaya said...

I am not able to navigate to next page.Jan 6, 2010 12:35:36 AM com.sun.faces.application.NavigationHandlerImpl getViewId
WARNING: "JSF1013: Unable to find matching navigation case from view ID '/LoginView.jsp' for outcome 'success' and action '#{user.login}'.I have mapped navigations correctly in faces-config.xml.

Can u help?

Can u help?

Anonymous said...

Hello,I'm using Eclipse IDE for Java EE Developers 1.2.1.20090918-0703.
With reference to point #4 in the tutorial.
In Preferences dialog, under Web>JavaServer Faces Tools,
I'm not getting the option of Libraries
and hence 'm unable to set the jar files of Mojarra1.2_09 as explained in the tutorial.
Plz help me on this.

Bauke Scholtz said...

Hmm, it has apparently changed in the latest Eclipse versions. You could skip this step and add the libraries in WEB-INF/lib yourself.

Anonymous said...

Hello, Can you please tell me, In which WEB-INF/lib folder do I need to copy the mojarra's 2 jar files? Whether it is Tomcat's WEB-INF/lib folder or something else's?
Also there are more than 1 WEB-INF folder that I could find.
Plz let me know.

Bauke Scholtz said...

In the web project.

Mihir Sakhadeo said...

Hello BalusC im a new programmer in JSF so can you suggest me some useful links where JSF has been explained in a great detail and in a very simple language

Jaya said...

Mihir
If your are a newbie go through
http://jsflessons.blogspot.com/

Unknown said...

Hi BalusC!
I guess you hear that too often, but I have to tell you, that your tutorial is really great! You helped me very much! Thank you!

Joey said...

Very well done! This is my first JSF tutorial and I feel like my time was well spent!

I love the screenshots as a validation that I am doing everything right, I know that must have slowed you down to get this article done but I bet it helped a lot of people too.

Great work!

Ruchir said...

Awesome tutorial... I am glad I found this tutorial on my second day with JSF. And believe me first day was frustrating. Thanks a lot for writing the tutorial and thinking through everything that a newbie will face.

Unknown said...

BalusC, this is an awesome tutorial and you are an awesome person - thank you!

Unknown said...

Thank you very much BalusC for this article in a detailed and descriptive manner.

Unknown said...

Hello, BalusC
Thank-you for your very clear tutorial.
I've got a small problem while creating the JSF library : on Helios, the JSF section doesn't include any library tab. So I created a simple user library to insert the two jsf jars.
When I used the template file in the Playground project, it showed me an error at the third line (about jstl). I tried to put the jstl jar in the project's library folder, but... same error !
Do you know the reason of my problem ?
Thank-you in advance.
Best regards !
Arno

Ömer Akgül said...

Hello BalusC thank you.
But ı have got same problem like arno. ı use helios and ı cant find the jsf library tap. pls. help us.
:(...

Abhishek Dhote said...

I am using JSF in one of my application and the scenario is as follows:

I have "pages" folder under "WEB"
in side "pages" I have "a.jsp"
When I deploy this application with the local tomcat and access the application it works perfectly ok
but when I deploy this application on my web hosting providers tomcat, it says "The requested resource (/pages/a.jsp) is not available."
In short the thing works perfectly OK on my local server but when I deploy this on my hosting providers tomcat, says reuqested resource not available.

Thanks | ABHI

Unknown said...

It seems the article needs to be appended because there is no chapter "Preferences - Web - JavaServer Faces Tools - Library" in Eclipse 3.6 (Helios).

I tried to add "jsf-api.jar" and "jsf-impl.jar" to "Preferences - Java - Build Path - User Libraries" and to "Project - Properties - Java Build Path" but despite on it I still get "ClassNotFoundException" on "com.sun.faces.config.ConfigureListener".
I also tried to restart Eclipse and Tomcat, and also tried to redeploy application, but it didn't help.

I solved this trouble by copying "jsf-api.jar" and "jsf-impl.jar" into tomcat's "lib" directory. But there should be more general solution, isn't it?

Arindam said...

Hi BalusC,

I rarely found documentation written so neatly. You have done an EXCELLENT JOB.
Each and every point you mentioned is well thought out.
I was struggling with configuring eclipse with Tomcat, JSF, facelet and your blog came to my rescue. many thanks !
-Arindam.

swaroop gokhale said...

Great Efforts

I have done excatly what you said from start till i run my first jsf application and I enjoied it

thanks

Unknown said...

Good post! I created the example project in MyEclipse and it's all done in a five minutes, thanks.

Unknown said...

Hi,Thanks for sharing your knowledge and guiding us,

can you please tell me why following error occured when i followed almost every step you mensioned,

com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.apache.myfaces.webapp.filter.TomahawkFacesContextFactory


I am using Eclipse Helios and tomcat 6.0.29

on my tomcat start up, it gives this error.

i have few jboss libraries included in it.
is that a reason why its bombing?

Please guide me..

Unknown said...

Great Article! thanks a lot.
It doesn't get any better than this ;-)

Mahesh said...

Hi Balu , we are migrating our project from jsf1.1 to jsf2.0,I am struggling with it, and the steps I followed are :Replaced the variables of type String in a java class with ValueExpression.Writing the xml file with the component, componentType and rendererType, using the same namespace from the xml file in the xhtml URI,But the error what am getting is
Error: JSF1068: Cannot instantiate component with component-type commandLink.
Can you please let me know where am going wrong or the migration steps to proceed.

mallikamt said...

Hi BalusC,
In your working with JSF, have you ever encountered this:
java.lang.NullPointerException: Argument Error: One or more parameters are null.
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeAttribute(HtmlResponseWriter.java:240)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.writeIdAttributeIfNecessary(HtmlBasicRenderer.java:504)
at com.sun.faces.renderkit.html_basic.TextRenderer.getEndTextToRender(TextRenderer.java:124)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:173)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:720)
at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.encodeChildren(CommandLinkRenderer.java:281)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:701)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:435)


We have recursive datatables on this page and it is hard hit..but we've been unable to pinpoint the problem. Thanks!
-Mallika

John said...

An absolute gem of a work.
Thanks man

Sachin said...

hiii, i am getting this error please resolve
Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener

Unknown said...

This tutorial is very easy to follow. Thanks for you efforts.

Leevy D. Malik said...

hi...balusC, i've follow the example of helloworld custom component in Ed Burns book, when running the example i got the "NullPointer error", i've double check all intructions and code but the problem still remain the same