facelets - JSF tag is not working on *.xhtml but working *.jsp file -


i trying run simple application using jsf 2.2, netbeans 7.3 , glassfish v2.

index.xhtml:

<?xml version='1.0' encoding='utf-8' ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"    xmlns:h="http://xmlns.jcp.org/jsf/html">     <h:head>         <title>facelet title</title>     </h:head>     <h:body>        <b>hello facelets</b>        <h:form id="this">            <h:outputtext value="this is"/>        </h:form>     </h:body> </html> 

web.xml:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">     <context-param>         <param-name>javax.faces.project_stage</param-name>         <param-value>development</param-value>     </context-param>     <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>/faces/*</url-pattern>     </servlet-mapping>     <session-config>         <session-timeout>             30         </session-timeout>     </session-config>     <welcome-file-list>         <welcome-file>faces/index.xhtml</welcome-file>     </welcome-file-list>   </web-app> 

output:


output file


the <b>hello facelets</b> working <h:outputtext value="this "/> not working. how caused , how can solve it?

i searched here , found following questions:

however, answers did not solve myproblem.


update: @xtreme biker, when changed said got following exception:

this exception

note: if used *.jsp instead of *.xhtml works. when make index file extension xhtml not working.

you're using glassfish v2, ancient java ee 5 container bundles jsf 1.2. webapp-supplied jsf default ignored , essentially, you're running jsf 1.2 time. explains why jsp works fine. facelets supported since jsf 2.0.

you have following options, depending on whether requirement being able use jsf 2.2, or being restricted glassfish v2:

  1. if you're restricted glassfish v2, can't use jsf 2.2 @ all. jsf 2.2 requires minimum of java ee 6 (glassfish 3). can use jsf 2.0 or 2.1. can download latest jsf 2.1 here (currently, 2.1.25). drop javax.faces.jar in /web-inf/lib , edit /web-inf/sun-web.xml add following entries <sun-web-app>:

    <class-loader delegate="false"/>  <property name="usebundledjsf" value="true" /> 

    this instruct glassfish prefer webapp-bundled jsf on own bundled jsf.


  2. if you're not restricted glassfish v2 , can upgrade it, possible. glassfish v2 ancient container may 2006 , succeeded glassfish 3 (java ee 6) in dec 2009 in turn succeeded glassfish 4 (java ee 7) in may 2013.

    glassfish 3.0 bundles jsf 2.0 , glassfish 3.1 bundles jsf 2.1. both upgradeable jsf 2.2 same way glassfish v2 difference sun-web.xml has been renamed glassfish-web.xml. way replacing jsf-api.jar+jsf-impl.jar or javax.faces.jar in glassfish's /modules directory desired version.

    glassfish 4.0 bundles jsf 2.2 , don't need manually supply jars. not recommend using glassfish 4.0. it's buggy (like every first major release of glassfish). better wait 4.0.1 (if ever comes out) or 4.1.


  3. if you're restricted glassfish v2 , can't upgrade jsf 2.x somehow, really, want use facelets, can install facelets 1.x separately. procedure described in this docbook. however, whilst you've got advantages of using facelets instead of jsp, sticking jsf 1.x disavantageous. wouldn't recommend that.