Over a million developers have joined DZone.

Java EE 7 Deployment Descriptors

DZone's Guide to

Java EE 7 Deployment Descriptors

· Java Zone ·
Free Resource

Java-based (JDBC) data connectivity to SaaS, NoSQL, and Big Data. Download Now.

As you might know by now, Java EE 7 will be released in a few days. There are many new features and I will not cover these novelties now. I just want to mention that most of the XML deployment descriptor namespaces have been updated. Nothing that will change your life as a developer, but as I mentioned on the Aquarium blog “It’s a symbol. For many years we were wondering what would happen to java.sun.com namespaces. Most of us thought it would be renamed to java.oracle.com. But no, it went back to where it originally belonged, to the JCP. Lately the JCP has moved towards greater transparency (i.e. JCP.next) and having the JCP namespaces strenghens this move“.

Basically, instead of having http://java.sun.com/xml/ns/javaee use http://xmlns.jcp.org/xml/ns/javaee. And of course, most of the XSD version numbers have been updated. So here are some of the new Java EE 7 namespaces.

CDI 1.1

The CDI deployment descriptor (beans.xml) is mandatory, even if it stays totally empty. Note that in CDI 1.1 (JSR 346) there is a new bean-discovery-mode element that informs CDI to discover all beans, none, or only annotated ones.

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all">

Bean Validation 1.1

Bean Validation 1.1 (JSR 349) is the only specification that hasn’t updated the namespace and still uses http://jboss.org/xml/ns. Note that Bean Validation and CDI specifications are both lead by RedHat

        xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.1.xsd"


        xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.1.xsd"

JPA 2.1

Only mandatory deployment descriptor in Java EE 7, the JPA 2.1 (JSR 338) persistence.xml files introduces new standard properties for schema generation (more on that in a coming post).


<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_1.xsd"


<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
                 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"

EJB 3.2

Not many changes in EJB 3.2 (JSR 342) compared to 3.1. So the ejb-jar.xml gently follows these minor updates.

<ejb-jar xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ejb-jar_3_2.xsd"

Servlet 3.1

Like the previous release, the web.xml in Servlet 3.1 (JSR 340) is optional as well as the web-fragment.xml.

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"

JSF 2.2

In JSF 2.2 (JSR 344) the faces-config.xml is still optional. Note that the namespaces of the component libraries have also been updated

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


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

JAX-WS 2.2

The WS-* landscape is defined in several specifications (JAX-WS 2.2a with JSR 224, Web Services 1.4 with JSR 109 and Web Services Metadata 2.1 with JSR 181). The webservices.xml deployment descriptor has been updated with the new namespace.

<webservices xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/javaee_web_services_1_4.xsd"


When you develop a Java EE 7 application make sure to use the new namespaces. I’ve just listed here the most common deployment descriptors but Java EE 7 has several extra ones (javaee_7.xsd, application_7.xsd, application-client_7.xsd,batchXML_1_0.xsd, jobXML_1_0.xsd…)).

Connect any Java based application to your SaaS data.  Over 100+ Java-based data source connectors.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}