Seam On GlassFish With Java Persistence
content="text/html; charset=ISO-8859-1">
In href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">Java
EE SDK Runs Seam I outlined some steps for getting href="http://www.jboss.com/products/seam">Seam (the JBoss
application framework that unifies JSF and EJB 3.0) to run on href="https://glassfish.dev.java.net/">GlassFish with Hibernate as
the persistence layer. Now, we'll see how we can have Seam
running on GlassFish with the href="https://glassfish.dev.java.net/javaee5/persistence/">Java
Persistence API as the persistence layer. For completeness,
I'll go over the prerequisites and setup as described in href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">Java
EE SDK Runs Seam because their are some subtle differences along
the way.
style="text-decoration: underline;">
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
href="http://sourceforge.net/project/showfiles.php?group_id=40712&package_id=127784&release_id=405151">Hibernate3
3.2cr1. - Download and install
href="http://sourceforge.net/project/showfiles.php?group_id=40712&package_id=156160&release_id=405227">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="http://weblogs.java.net/blog/rogerk/archive/copyHibernateLibsJPersist.sh">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
href="http://prdownloads.sourceforge.net/jboss/jboss-seam-1.0beta2.zip?download">here.
You should see a jboss-seam-1.0beta2 directory. - Get the zip files:
href="http://weblogs.java.net/blog/rogerk/archive/seam-core-patch.zip">seam-core-patch.zip
and href="http://weblogs.java.net/blog/rogerk/archive/seam-booking-jpersist-patch.zip">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
style="font-style: italic;"><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: style="font-style: italic;"><glassfish install dir>/javadb/lib/derbytools.jar: style="font-style: italic;"><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// style="font-style: italic;"><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
href="http://weblogs.java.net/blog/rogerk/archive/2006/04/java_ee_sdk_run_1.html">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
style="font-style: italic;">---->
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
style="font-style: italic;">
style="color: rgb(255, 0, 0);">----> made SQL queries complete for
Java Persistence.
- Login or register to post comments
- Printer-friendly version
- rogerk's blog
- 2200 reads





