Seam (FCS) On GlassFish
Posted by rogerk on July 25, 2006 at 1:45 PM EDT
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:
- 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.0.1.GA release from here. You should see a jboss-seam-1.0.1.GA directory.
- Get the zip file: seam-1.0.1.GA-booking-patch.zip
.
- Go to the jboss-seam-1.0.1.GA directory and unzip seam-1.0.1.GA-booking-patch.zip.
- Copy jboss-seam-1.0.1.GA/lib/thirdparty-all.jar to <glassfish install dir>/lib
- 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
- Compile Seam Booking Application:
- Go to the jboss-seam-1.0.1.GA/examples/booking directory
- ant
- Start up Glassfish.
- Start the database: <glassfish install dir>/bin/asadmin start-database
- Deploy jboss-seam-1.0.1.GA/examples/booking/build/jboss-seam-booking.ear
- Go to jboss-seam-1.0.1.GA/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
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 >>
Blog Links >>
- Login or register to post comments
- Printer-friendly version
- rogerk's blog
- 1571 reads





