Skip to main content

Seam On GlassFish With Java Persistence

Posted by rogerk on May 4, 2006 at 2:50 PM PDT

content="text/html; charset=ISO-8859-1">

In  href="">Java
EE SDK Runs Seam I outlined some steps for getting href="">Seam (the JBoss
application framework that unifies JSF and EJB 3.0) to run on href="">GlassFish with Hibernate as
the persistence layer.  Now, we'll see how we can have Seam
running on GlassFish with the href="">Java
Persistence API as the persistence layer.  For completeness,
I'll go over the prerequisites and setup as described in href="">Java
EE SDK Runs Seam because their are some subtle differences along
the way.

style="text-decoration: underline;">


  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.0beta2 release from href="">here. 
    You should see a jboss-seam-1.0beta2 directory.
  2. Get the zip files: href="">
    and href="">

  3. Go to the jboss-seam-1.0beta2 directory and unzip and

Compilation Procedure:

  1. Copy <glassfish install dir >/lib/javaee.jar
    to jboss-seam-1.0beta2/lib directory.
  2. Copy jboss-seam-1.0beta2/lib/jboss-common.jar style="font-style: italic;"><glassfish install dir>/lib 
    (needed for JBoss Logger)
  3. Compile Seam core classes:
    • Create an empty jboss-seam-1.0beta2/src/test directory (the
      build file is looking for this directory that is not there from the
      seam zip file).
    • Go to jboss-seam-1.0beta2 directory;  ant;
  4. Compile Seam Booking Application:
    • Copy jboss-seam-1.0beta2/jboss-seam-ui.jar to
    • Go to jboss-seam-1.0beta2/examples/booking
    • ant

Deploy the application:

  1. Start up Glassfish.
  2. Start the database:  <glassfish
    install dir>
  3. Deploy

Load the database:

  1. Go to jboss-seam-1.0beta2/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

You can refer to href="">Java
EE SDK Runs Seam for an explanation of the Seam core
modules and the Seam Booking application modules that required
modification.  Those modifications are essentially the same with
the exception of the following modifications to some Booking
application modules:


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




examples/booking/src/org/jboss/seam/example/booking/ style="font-style: italic;">

           style="color: rgb(255, 0, 0);">----> made SQL queries complete for
Java Persistence. 


Related Topics >>