Posted by
rogerk on May 4, 2006 at 2:50 PM PDT
Seam-GlassFish
In
Java
EE SDK Runs Seam I outlined some steps for getting
Seam (the JBoss
application framework that unifies JSF and EJB 3.0) to run on
GlassFish with Hibernate as
the persistence layer. Now, we'll see how we can have Seam
running on GlassFish with the
Java
Persistence API as the persistence layer. For completeness,
I'll go over the prerequisites and setup as described in
Java
EE SDK Runs Seam because their are some subtle differences along
the way.
Prerequisites:
- A working build environment with ant,
at least JDK 5,
and GlassFish
(build 43 or later).
- You'll need to use some of the Hibernate libraries that the Seam framework depends on:
- Download and install Hibernate3
3.2cr1.
- Download and install Hibernate
EntityManager 3.1 beta7 . Note that hibernate-entitymanager.jar is not
required because we'll be using Java Persistence. However, hibernate-annotations.jar is still
required, because the Seam framework uses classes from the Hibernate validator package.
- Copy the required hibernate jars into Glassfish lib dir.
The script 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:
- Download and install the Seam 1.0beta2 release from here.
You should see a jboss-seam-1.0beta2 directory.
- Get the zip files: seam-core-patch.zip
and seam-booking-jpersist-patch.zip
.
- Go to the jboss-seam-1.0beta2 directory and unzip
seam-core-patch.zip and seam-booking-jpersist-patch.zip.
Compilation Procedure:
- Copy <glassfish install dir >/lib/javaee.jar
to jboss-seam-1.0beta2/lib directory.
- Copy jboss-seam-1.0beta2/lib/jboss-common.jar <glassfish install dir>/lib
(needed for JBoss Logger)
- 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;
- Compile Seam Booking Application:
- Copy jboss-seam-1.0beta2/jboss-seam-ui.jar to
jboss-seam-1.0beta2/examples/booking/resources/WEB-INF/lib
- Go to jboss-seam-1.0beta2/examples/booking
- ant
Deploy the application:
- Start up Glassfish.
- Start the database: <glassfish
install dir>/bin/asadmin
start-database
- Deploy
jboss-seam-1.0beta2/examples/booking/build/jboss-seam-booking.ear
Load the database:
- Go to jboss-seam-1.0beta2/examples/booking/resources
- set your CLASSPATH so that it is:
- CLASSPATH=<glassfish install dir>/javadb/lib/derbyclient.jar:<glassfish install dir>/javadb/lib/derbytools.jar:<glassfish install dir>/javadb/lib/derby.jar:.
- java -Dij.driver='org.apache.derby.jdbc.ClientDriver'
org.apache.derby.tools.ij
- At the Derby ij prompt connect to the default database:
- connect 'jdbc:derby://localhost:1527//<glassfish install dir>/bin/sun-appserv-samples';
- For example: connect
'jdbc:derby://localhost:1527///home/work/glassfish/bin/sun-appserv-samples';
- run 'import.sql';
- Now the Seam application tables should be loaded.
Run the application:
- visit localhost:8080/seam-booking
You can refer to
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:
examples/booking/resources/META-INF/persistence.xml
---->
updated for application with
GlassFish and Java
Persistence
examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java
examples/booking/src/org/jboss/seam/example/booking/HotelBookingAction.java
examples/booking/src/org/jboss/seam/example/booking/LoginAction.java
examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java
----> made SQL queries complete for
Java Persistence.