The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


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.

Prerequisites:
  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 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:
  1. Download and install the Seam 1.0.1.GA release from here.  You should see a jboss-seam-1.0.1.GA directory.
  2. Get the zip file: seam-1.0.1.GA-booking-patch.zip
  3. Go to the jboss-seam-1.0.1.GA directory and unzip seam-1.0.1.GA-booking-patch.zip.
Compilation Procedure:
  1. Copy jboss-seam-1.0.1.GA/lib/thirdparty-all.jar to <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>/bin/asadmin start-database
  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:<glassfish install dir>/javadb/lib/derbytools.jar:<glassfish install dir>/javadb/lib/derby.jar:.
  3. java -Dij.driver='org.apache.derby.jdbc.ClientDriver' org.apache.derby.tools.ij
  4. 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

Code Change Summary

The following changes apply to the Seam Booking application:

./examples/booking/resources/import.sql
----> Added trailing semicolons to each sql statement
./examples/booking/resources/META-INF/persistence.xml
----> Updated for application with GlassFish and Java Persistence
./examples/booking/resources/META-INF/ejb-jar.xml
----> Updated per EJB 3 schema: added schema namespace and <interceptors> element
./examples/booking/resources/WEB-INF/web.xml
----> Added schema namespace
---->Updated JNDI lookup pattern
---->Disabled MyFaces StartupServletContextListener - we're using JSF 1.2
---->Added <ejb-local-ref> elements for EJB applicaton actions
./examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java
./examples/booking/src/org/jboss/seam/example/booking/HotelSearchingAction.java
./examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java
./examples/booking/src/org/jboss/seam/example/booking/LoginAction.java
----> Updated sql statements passed to EntityManager.createQuery
./examples/booking/src/org/jboss/seam/example/booking/User.java
---->Refer to table name 'Users'
./examples/booking/view/conversations.xhtml
---->Added <ui:composition> element

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

./src/ui/org/jboss/seam/ui/HtmlLink.java
---->Added encodeEnd method to properly end either an HTML input element or an HTML hyperlink element


All of these entries are in the seam-1.0.1.GA-booking-patch.zip file and can be reviewed.
Related Topics >> J2EE      
Comments
Comments are listed in date ascending order (oldest first)