Question

When I add the following line in the faces-config.xml file:

" <application><view-handler>com.sun.facelets.FaceletViewHandler</view-handler></application> "

eclipse says:

" view-handler references to "com.sun.facelets.FaceletViewHandler" that does not implement interface javax.faces.application.ViewHandler

configure problem severity for preference 'invalid view handler' "

However, I added the libraries in the "lib" of "WEB-INF" of my jsf project. When I deploy my ear and jsf projects, they deploy correctly, but the execution of my jsf page, I get an error:

" javax.servlet.ServletException: /AddUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag
was defined for name: head
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) "

and in the console, I have:

14:05:49,420 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/primefaces-3.5.jar/META-INF/primefaces-p.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/primefaces-3.5.jar/META-INF/primefaces-p.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/primefaces-3.5.jar/META-INF/primefaces-p.taglib.xml@5,17]
...
14:05:49,450 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-fn.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-fn.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-fn.taglib.xml@47,31]
...
14:05:49,469 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-core.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-core.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/jstl-core.taglib.xml@47,31]
...
14:05:49,479 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/ui.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/ui.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/ui.taglib.xml@47,31]
...
14:05:49,479 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/facelets_jsf_core.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/facelets_jsf_core.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/facelets_jsf_core.taglib.xml@47,31]
...
14:05:49,479 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/composite.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/composite.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/composite.taglib.xml@47,29]
...
14:05:49,489 GRAVE [facelets.compiler] Error Loading Library: vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/html_basic.taglib.xml: java.io.IOException: Error parsing [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/html_basic.taglib.xml]: 
...
Caused by: org.xml.sax.SAXException: Error Handling [vfs:/C:/Users/citech/Desktop/testjsf/jsf/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_6.x_Runtime_Server1368781328313/deploy/helloworldjsf.war/WEB-INF/lib/jsf-impl-2.1.6.jar/com/sun/faces/metadata/taglib/html_basic.taglib.xml@47,31]
...
14:05:49,499 GRAVE [facelets.viewhandler] Error Rendering View[/AddUser.xhtml]: com.sun.facelets.tag.TagException: /AddUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head
...
14:05:49,499 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/helloworldjsf].[Faces Servlet]] "Servlet.service()" pour la servlet Faces Servlet a généré une exception: com.sun.facelets.tag.TagException: /AddUser.xhtml @9,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head
...

But when I remove the line in the faces_config.xml: and I redeploy my projects, they are deployed well and my jsf page opens. When I validate the form so that it records in the database, it returns me the same page and in the console, there is the following error:

"  INFO  [STDOUT] UserBeanCtrl.addUser(): Erreur d'initialisation du contexte JNDI<javax.naming.NamingException: Could not dereference
object [Root exception is java.lang.RuntimeException: Can not find
interface declared by Proxy in our CL +
org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@526f437d]> "

I do not understand what is happening.

faces-config.xml

    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-facesconfig_2_0.xsd"
    version="2.0">
 <managed-bean>
  <managed-bean-name>userBeanVue</managed-bean-name>
  <managed-bean-class>net.viralpatel.jsf.helloworld.UserBeanVue</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <managed-bean>
  <managed-bean-name>userBeanCtrl</managed-bean-name>
  <managed-bean-class>net.viralpatel.jsf.helloworld.UserBeanCtrl</managed-bean-class>
  <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>
 <navigation-rule>
  <display-name>AddUser</display-name>
  <from-view-id>/AddUser.xhtml</from-view-id>
  <navigation-case>
   <from-outcome>success</from-outcome>
   <to-view-id>/ListUser.xhtml</to-view-id>
  </navigation-case>
 </navigation-rule>
 <application>
  <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
 </application>
</faces-config>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>helloworldjsf</display-name>
  <context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>bluesky</param-value>
  </context-param>
  <context-param>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>2</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <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>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>
Was it helpful?

Solution

It look like that you're mixing JSF 1.x, Facelets 1.x and JSF 2.x. You've there a JSF 2.0 compatible faces-config.xml root declaration, but you're still declaring managed beans and navigation cases the legacy JSF 1.x way (those entries are not needed anymore in JSF 2.x thanks to the @MangedBean annotation and implicit navigation feature). Perhaps you were reading wrong books/tutorials/resources while attempting to learn JSF 2.x.

Also, the ViewHandler implementation which you mentioned there is from Facelets 1.x which is only necessary when you're still using the legacy JSF 1.x. However, since JSF 2.x, Facelets 2.x is bundled in the JSF API/implementation JARs and has become the default view technology, thus there is no need to have a separate Facelets JAR file nor to manually register its view handler in faces-config.xml.

The tag error on <h:head> also confirms that you're actually using JSF 1.x JARs during runtime instead of JSF 2.x as the <h:head> was introduced in JSF 2.x and absent in JSF 1.x.

Get rid of all JSF 1.x and Facelets 1.x related JARs and make sure that you've downloaded and installed the JSF 2.x ones (or just don't download any as JBoss 6x by itself already ships with JSF 2.x bundled, so effectively having a completely empty /WEB-INF/lib should also be sufficient in order to get JSF 2.x to run). Throw away those JSF 1.x books/tutorials/resources and head to JSF 2.x ones. Our JSF wiki page is a good starting point.

As to the XML configuration files, ultimately, you should end up with an empty faces-config.xml and only the following entry in web.xml:

<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>*.xhtml</url-pattern>
</servlet-mapping>

Add if necessary the PrimeFaces theme back, if the default of "aristo" isn't what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top