Archive for February 28th, 2007

Glassfish and Seam Tips

Wednesday, February 28th, 2007

The Seam forum regularly gets questions about Glassfish -- it is probably the third most popular platform for Seam apps behind JBoss AS and Tomcat. Here are some tips on how to make Seam apps work best on Glassfish.

1. Enable Seam logging in Glassfish: Seam uses log4j to log. Glassfish does not support log4j by default. You need to include a log4j.xml file in the JAR file for EJB3 beans (the myapp.jar file inside myapp.ear). For an example, check out the new examples/glassfish example in Seam 1.2 GA.

2. Must include the SeamELResolver: In order for Glassfish to resolve the Seam EL expressions correctly, you need to add an SeamELResolver to faces-config.xml.

XML:
  1. <faces-config version="1.2"
  2.    xmlns="http://java.sun.com/xml/ns/javaee"
  3.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  5.       http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
  6.  
  7.     <application>
  8.         <el-resolver>org.jboss.seam.jsf.SeamELResolver</el-resolver>
  9.     </application>
  10.  
  11.     <!-- Select one of the standard transaction models for the Seam application -->^M
  12.     <lifecycle>
  13.         <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
  14.     </lifecycle>
  15. </faces-config>

If not, you will not be able to reference Seam built-in component using their shorthand names (e.g., #{conversationList} and #{identity} etc.). This is the cause of the issues discussed here and here in the forum.

3. No need for the el-*.jar: Since Glassfish already bundles JSF 1.2, there is no need to include the el-*.jar files in your EAR file and reference them in application.xml.

Let me know if you have more tips on how to get Glassfish and Seam work more smoothly together. :)