JSF 2.2: New namespaces

In this post of the series on JSF 2.2 I will show the new XML namespaces used by JSF 2.2 for faces-config.xml, custom tag lib config files and JSF taglibs. Basically, all namespaces start with http://xmlns.jcp.org now instead of http://java.sun.com. So one more remnant of the Sun era that was removed.

Like many versions of JSF before, JSF 2.2 defines new versions of the schemas for the faces-config.xml and custom tag lib config files. But this time the complete namespace is changed from http://java.sun.com/xml/ns/javaee to http://xmlns.jcp.org/xml/ns/javaee additionally for all schemas. This applies for all parts of Java EE 7 by the way.

The following listing shows a JSF 2.2 faces-config.xml:

<faces-config version="2.2"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">

The following listing shows a JSF 2.2 taglib config file:

<facelet-taglib version="2.2"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">

Beside the config file schemas, JSF 2.2 also changes the namespaces for all JSF taglibs. Good news, everyone! The old taglib namespaces are still supported in case you are planning to migrate an existing application. The following table shows the old and new namespaces for the most important JSF taglibs.

Old namespace JSF 2.2 namespace
http://java.sun.com/jsf/core http://xmlns.jcp.org/jsf/core
http://java.sun.com/jsf/html http://xmlns.jcp.org/jsf/html
http://java.sun.com/jsf/facelets http://xmlns.jcp.org/jsf/facelets
http://java.sun.com/jsf/composite http://xmlns.jcp.org/jsf/composite
http://java.sun.com/jsp/jstl/core http://xmlns.jcp.org/jsp/jstl/core
http://java.sun.com/jsp/jstl/functions http://xmlns.jcp.org/jsp/jstl/functions

You can see the root element of a Facelets view with some new JSF 2.2 namespaces in the next listing. It includes the Core Taglib, the HTML Taglib and a custom composite component taglib.

<html xmlns="http://www.w3.org/1999/xhtml"

The examples for the JSF 2.2 series in the JSFlive Github repository jsf22-examples contain various examples for the new namespaces.

Further official details about JSF 2.2 can be found in the JSR 344: JavaServer Faces 2.2.


There used to be a bug in Mojarra before version 2.2.1 which prevented the new taglib namespaces from working for for all tags (see JAVASERVERFACES-2868 for details). With Mojarra 2.2.1 this bug was fixed.


8 responses to “JSF 2.2: New namespaces

  1. Pingback: JavaEE 7 最全教程集锦 | Java,go's的个人博客

  2. Pingback: JSF 2.0 namespaces | Kev's Development Toolbox

  3. Seems current Eclipse Kepler SR2 is not aware of these new namespaces. The editor shows me warnings
    “NLS missing message: CANNOT_FIND_FACELET_TAGLIB in: org.eclipse.jst.jsf.core.validation.internal.facelet.messages”
    These warnings disappear as soon as I switch back to the old namespaces.

    • Sorry, I don’t use (or like) Eclipse. I quickly tried to get it running with a local Eclipse 4.2 – but no success. With IntelliJ 13 this works like a charm.

      But it should be no problem to stick with the old namespaces with JSF 2.2 for now. Maybe Eclipse will support the new ones in 1 or 2 years 😉

    • I tried Eclipse 4.3.2 now, too. When I import the JSF 2.2 Maven projects from my book, code completion works with the new namespaces. Do you have the project facet JavaServer Faces enabled and set to version 2.2?

      • Yes, I have the JSF 2.2 facet set in my project. But it can’t handle the new namespaces 😦
        Which JSF dependencies do you have in your POM?

      • I think in this example I have com.sun.faces:jsf-api:2.2.2 and com.sun.faces:jsf-impl:2.2.2.

  4. Pingback: Glassfish 3 nach Wildfly 9 migrieren – Informatikwerk GmbH

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s