Annoying NetBeans 6.0 Facelets Support Issue on Tomcat

Yesterday i got a call from a good friend of mine who has been dipping his fingers into JSF a bit. He’d decided to jump ship to using JSF on XHTML files, a technology known as Facelets. So he goes to download NetBeans 6.0 Facelets support plugin and installs it.

After developing a simple facelets page, he decides to deploy it to Tomcat 6.0.14 only to get BIG FAT class loader exceptions. What better way to treat a sceptic who is just getting into the game of web development in Java. These are the kind of things that can be so annoying about doing something in Java. Being a Seam advocate and user, I didn’t immediately realise what could have been the problem, since my Seam applications run fine using the jars from Seam.

After doodling around and making some changes to jars that came with the Facelets support, i just decided to ditch the jars from Facelets support and use my own. I picked the jars that come with Seam and VOILA! Problem solved. Makes me wonder if the guys who developed the plugin didn’t try to deploy it themselves AT LEAST to Tomcat before putting it out there. Anyways i just felt like putting up the solution to this simple but very annoying problem here for the sake of those who might try an introduction to Facelets.

Note that i got these jars from the JBoss Seam 2.0.GA’s lib folder. I can’t tell you where u can get them individually but downloading seam altogether will give you a change to start playing around with it if you haven’t started already.

Simply create a new Library in NetBeans by going to Tools->Libraries. I gave mine the name Facelets4Tomcat. Here are the jar files you need.

  • commons-beanutils.jar
  • commons-collections.jar
  • commons-digester.jar
  • commons-logging.jar
  • jboss-el.jar
  • jsf-api.jar
  • jsf-facelets.jar
  • jsf-impl.jar

This goes into your web.xml file.

<servlet-name>Faces Servlet</servlet-name>

<servlet-name>Faces Servlet</servlet-name>

If you want to add the Ajaxified RichFaces components then add the following from the same Seam lib folder.

  • richfaces-api.jar
  • richfaces-ui.jar
  • richfaces-impl.jar

And add these to the top of your web.xml file

<display-name>RichFaces Filter</display-name>

You may use a different skin if you want. Check out the documentation for details

You may then add the library you created to your project by right clicking your web project and selecting “Properties”. At Libraries, click “Add Library” and selected the library you just created. Make sure that the check box is enabled or else it will not put the jar files in the right location i.e. WEB-INF/lib.

Oh, and MAKE SURE that the Facelets support libraries are unchecked, or else you’ll be back to square 1.

Happy Faceleting.


7 thoughts on “Annoying NetBeans 6.0 Facelets Support Issue on Tomcat

  1. Hi Edem,
    I really appreciate the help, just followed the instructions and it worked like magic, but I would like to say that you never made mention of the faces-config.xml file.

    I suggest that you include the final contents of the web.xml and the faces-config.xml for others to crosscheck that they are doing the right thing. Perhaps, some screen captures would also be appreciated by many eager learners. Thanks.

  2. Ah. Thanks for the suggestion. Better still I’ve created a little Facelet application which you can download and follow to be sure about configuration. It will ask you for a Facelets4Tomcat dependency. Just create a Library in NetBeans with that name and load up the above mentioned jars, and u should be good to go.
    Her’es the url

  3. Pingback:

  4. Hi,

    I agree with you Edem, the guys who develops librairies like Facelets would not only build their librairies and tell us : Use our stuff by your own way, do as you can to make work on your infrastructure. (By the way, good luck…)

    They should also maintains at least a tiny web site where they publish working exemples. By working exemples I mean tiny application like “Hello world” working on all major servlet containers and J2EE application servers. I mean Tomcat 5.5.x, Tomcat 6.0.x, OC4J 9.x, OC4J 10.x, OC4J 11.x, WebSphere 5.x, WebSphere 6.x, JBoss and GlassFish. If for any reasons they discovers that their “Hello world” application don’t work on one of them, they would write a little warning on their site telling us that the are working on a fix or that they can’t fix it and explain why they can’t. They write their stuff, they must be able to make it works on any major server, so they are able to give us some ready to run WAR or EAR files (with all the required librairies or with detailled instructions explaining how to configure the server to make it able to run their “Hello world” app)

    Now, let’s talk about Facelets. I used Facelets in 2006 in a web application which we developped with Eclipse 3.x, tested on Tomcat 5.5.x and deployed on OC4J 10.1.3.x. I worked fine, very fine, so fine that I choose Facelets as my favorite templating technology (instead of Apache Tiles). It still work very fine on Tomcat 5.5.x.

    BUT, recently in choose to migrate my projets from Tomcat 5.5.x to Tomcat 6.0.x. What a nightmare !!! Tomcat 5.5.x is ready for servlet 2.4 and JSP 2.0 while Tomcat 6.0.x is ready for servlet 2.5 and JSP 2.1. This seams to be a “big deal”, but it cause big fat ugly class loader problems and exceptions with Facelets 1.1.14. Tomcat 6 come with a version of jsp-api.jar which seam to conflicts with Facelets 1.1.14.

    Now, I am googling to find a list of jars (with version numbers) which will allow me to use all these “librairies” together :
    – Facelets 1.1.14
    – Hibernate 3.3.x
    – JSF 1.2_x
    – Log4J 1.2.15
    – MyFaces 1.2.x
    – Spring 2.5.x
    – Struts 1.3.10
    – Tomahawk 1.1.x
    – XStream 1.3.x

    I do not plan to use JBoss Seam, but if this is the only way to get all my stuff working together is to use JBoss Seam’s jars, I’m willing to download the latest JBoss Seam to get these jars.

    Is there someone here who know all these “librairaies” enough to help me to find the better jar files list to make it works without class loader problems?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s