Glassfish and Seam Tips

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. :)

6 Responses to “Glassfish and Seam Tips”

  1. marcus Says:

    A recent doc change in Seam notes that selection of the JDK logger vs log4j is automagic. I haven’t followed this development, so I’m not sure if its a recent change or relevant to your first point.
    http://fisheye.labs.jboss.com/browse/JBoss/jboss-seam/doc/reference/en/modules/concepts.xml?r1=1.52&r2=1.53

  2. Michael Yuan Says:

    Thanks Marcus. I think that paragraph applies to loggers that you injected into your Seam application. Seam itself still uses Log4J to output its debug messages AFAIK. :)

  3. Gavin Says:

    Naw, actually this has been true for a while: we automatically choose log4j vs jdk logging for all logging. I just forgot to update the docs….

  4. Pascal J Says:

    Why not code against the SLF4J API so that SEAM, Hibernate & all is independent of the logging implementation (could be Log4j, Logback or JDK logger) ?

  5. Joshua Says:

    I wrote how to easily install Seam POJO apps on Glassfish here.

  6. Nikola Says:

    Hi Michael, I am constantly encountering ClassNotFoundException : org.jboss.seam.jsf.SeamELResolver
    every time when I run Glassfish example
    on page
    http://www.coffeecrew.org/docs/html/netbeansFaceletsSeamEjb3/netbeansFaceletsSeamEjb3.html

    . Would you mind to mail me , if you know the
    cause of my error.
    I properly added resolver in faces-config.xml,
    also jboss-seam.jar is in my classpath.

Leave a Reply