Seam On GlassFish With Java Persistence
Posted by rogerk on May 4, 2006 at 5:50 PM EDT
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.
- 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.
- 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
- 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
- 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.
- 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.
Related Topics >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- rogerk's blog
- 2066 reads





