Skip to main content

Seam (FCS) On GlassFish

Posted by rogerk on July 25, 2006 at 10:45 AM PDT

So far we've seen how we can get Seam running on GlassFish with Hibernate Persistence and Java Persistence. Modifications were needed to the Seam core classes as well as the application classes. Fortunately, JBoss has made the modifications to their core classes in time for their Seam FCS release. In this entry we'll outline the steps to get the Seam FCS release up and running on GlassFish with Java Persistence.


  1. A working build environment with ant,
    at least JDK 5,
    and GlassFish
    (build 43 or later).
  2. You'll need to use some of the Hibernate libraries that the Seam framework depends on:
    • Download and install href="">Hibernate3
    • Download and install href="">Hibernate
      EntityManager 3.1 beta7 .  Note that style="font-style: italic;">hibernate-entitymanager.jar is not
      required because we'll be using Java Persistence.  However, style="font-style: italic;">hibernate-annotations.jar is still
      required, because the Seam framework uses classes from the Hibernate style="font-style: italic;">validator package.
    • Copy the required hibernate jars into Glassfish lib dir.
      The script href="">here
      contains the list of jars.
    • Edit the script to make sure it references your Glassfish and
      Hibernate install directories.
    • Execute the script.

Seam Setup:

  1. Download and install the Seam 1.0.1.GA release from href="">here. 
    You should see a jboss-seam-1.0.1.GA directory.
  2. Get the zip file: href="">

  3. Go to the jboss-seam-1.0.1.GA directory and unzip

Compilation Procedure:

  1. Copy jboss-seam-1.0.1.GA/lib/thirdparty-all.jar to style="font-style: italic;"><glassfish install dir>/lib 
  2. Compile Seam core classes - this will compile the HtmlLink class in the ui package.
    • Go to the jboss-seam-1.0.1.GA directory
    • ant
  3. Compile Seam Booking Application:
    • Go to the jboss-seam-1.0.1.GA/examples/booking directory
    • ant

Deploy the application:

  1. Start up Glassfish.
  2. Start the database:  <glassfish
    install dir>
  3. Deploy jboss-seam-1.0.1.GA/examples/booking/build/jboss-seam-booking.ear

Load the database:

  1. Go to jboss-seam-1.0.1.GA/examples/booking/resources
  2. set your CLASSPATH so that it is:
    • CLASSPATH=<glassfish install dir>/javadb/lib/derbyclient.jar: style="font-style: italic;"><glassfish install dir>/javadb/lib/derbytools.jar: style="font-style: italic;"><glassfish install dir>/javadb/lib/derby.jar:.
  3. java -Dij.driver='org.apache.derby.jdbc.ClientDriver'
  4. At the Derby ij prompt connect to the default database:
    • connect 'jdbc:derby://localhost:1527// style="font-style: italic;"><glassfish install dir>/bin/sun-appserv-samples';
      • For example: connect
    • run 'import.sql';
  • Now the Seam application tables should be loaded.

Run the application:

  • visit localhost:8080/seam-booking

Code Change Summary

The following changes apply to the Seam Booking application:


style="font-style: italic;">---->
Added trailing semicolons to each sql statement


style="font-style: italic;">---->
Updated for application with
and Java


style="font-style: italic;">---->
Updated per EJB 3 schema: added schema namespace and style="font-style: italic;"><interceptors>


style="font-style: italic;">---->
Added schema namespace
---->Updated JNDI lookup pattern
---->Disabled MyFaces StartupServletContextListener - we're using JSF 1.2
---->Added style="font-style: italic;"><ejb-local-ref>
elements for EJB applicaton actions





style="font-style: italic;">---->
Updated sql statements passed to EntityManager.createQuery


style="font-style: italic;">---->Refer to table name 'Users'


style="font-style: italic;">---->Added <ui:composition> element

The following change is to a Seam (JSF) custom component:


style="font-style: italic;">---->Added encodeEnd method to properly end either an HTML input element or an HTML hyperlink element

All of these entries are in the file and can be reviewed.

Related Topics >>