4.2. Java EE 6 upgrade

Seam 2.3 can integrate with the major upgrades in Java EE 6. You can use persistence with JPA 2, EJB 3.1, and Bean Validation. EE 6 technology upgrades require a change in the XML schema declaration. For details, see Section 4.1.2, “Java EE 6 schema changes”.

4.2.1. Using Bean Validation standard instead of Hibernate Validator

Bean Validation is a standard included in Java EE 6 as a new technology. Seam uses Hibernate Validator, which is a reference implementation.
You need to migrate from using org.hibernate.validator.* Hibernate validator annotations to javax.validation.constraint.*. Seam examples use many of the following annotations (Using Bean Validation):
  • org.hibernate.validator.Length to javax.validation.constraint.Size.
  • org.hibernate.validator.NotNull to javax.validation.constraint.NotNull.
  • org.hibernate.validator.Pattern to javax.validation.constraint.Pattern.

4.2.2. Migration of JSF 1 to JSF 2 Facelets templates

For using JSF 2 in a simple application, migrate only web.xml file. The configuration file faces-config.xml is not required. However, for information on migrating faces-config.xml file, see Example 4.8, “faces-config.xml”.
All JSF templates in your application must use facelets technology only, as JSP is deprecated.
In the facelet templates, convert <head>/<body> tags to ><h:head>/<h:body>, respectively.
The upgrade from JSF 1.x to JSF 2.x differs depending on the JSF components used (for example, Richfaces or Icefaces). You may need to upgrade libraries entirely. See a component framework documentation for details of these changes. Migration of these independent components is not covered here.

4.2.3. Using s:validate and s:validateAll in JSF 2

In Seam 2.3, JSF 2 adds bean validators to all the fields by default. The s:validateAll tag ignores the fields to which JSF 2 has added bean validators.
To use the s:validate tag or s:validateAll tag in Seam 2.3, disable the JSF default bean validator view settings. Set javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR context parameter to true in the application's web.xmlfile.

4.2.4. Migration to JPA 2.0

To use JPA 2, change the version in persistence.xml file to 2.0, see Example 4.5, “persistence.xml”. The version in application.xml file should be 6 if you are using EAR (Example 4.6, “application.xml”), or version 3.0 in web.xml file if you use only WAR archives (Example 4.7, “web.xml”).

Note

Most applications can use WAR with EJB 3.1 and not require to be packaged as an EAR.
JPA 2.0 is backward compatible with JPA 1.0, so do not migrate JPA annotations or classes.

4.2.5. Using compatible JNDI for resources

Java EE 6 brings a new set of standardized global rules for creating portable JNDI syntax. Change all JNDI strings from _your_application_/#{ejbName}/local to java:app/_application-module-name_/#{ejbName}. For example, WEB-INF/components.xml jndiPattern changes from:
seam-mail/#{ejbName}/local
to:
java:app/seam-mail-ejb/#{ejbName}