You're using GlassFish v2, which is an ancient Java EE 5 container which already bundles JSF 1.2. The webapp-supplied JSF is by default ignored and essentially, you're running JSF 1.2 all the time. That explains why JSP works fine. Facelets is only supported since JSF 2.0.
You have the following options, depending on whether your requirement is being able to use JSF 2.2, or being restricted to GlassFish v2:
If you're restricted to GlassFish v2, then you can't use JSF 2.2 at all. JSF 2.2 requires a minimum of Java EE 6 (GlassFish 3). You can however use JSF 2.0 or 2.1. You can download latest JSF 2.1 from here (currently, 2.1.25). Drop the
javax.faces.jar
in/WEB-INF/lib
and edit the/WEB-INF/sun-web.xml
to add the following entries to<sun-web-app>
:<class-loader delegate="false"/> <property name="useBundledJsf" value="true" />
This will basically instruct GlassFish to prefer webapp-bundled JSF over its own bundled JSF.
If you're not restricted to GlassFish v2 and can upgrade it, then do it as soon as possible. GlassFish v2 is an ancient container from May 2006 and succeeded by GlassFish 3 (Java EE 6) in Dec 2009 which is in turn succeeded by GlassFish 4 (Java EE 7) in May 2013.
GlassFish 3.0 bundles JSF 2.0 and GlassFish 3.1 bundles JSF 2.1. But both are upgradeable to JSF 2.2 the same way as GlassFish v2 with the difference that
sun-web.xml
has been renamed toglassfish-web.xml
. Another way is simply replacing thejsf-api.jar
+jsf-impl.jar
orjavax.faces.jar
in GlassFish's/modules
directory by the desired version.GlassFish 4.0 bundles JSF 2.2 and you don't need to manually supply any JARs. I would currently however not recommend using GlassFish 4.0. It's too buggy (like as every first major release of GlassFish). Better wait for 4.0.1 (if it ever comes out) or a 4.1.
If you're restricted to GlassFish v2 and can't upgrade to JSF 2.x somehow, but you really, really want to use Facelets, then you can always install Facelets 1.x separately. The procedure is described in this docbook. However, whilst you've got the advantages of using Facelets instead of JSP, sticking to JSF 1.x is disavantageous. I really wouldn't recommend that.