 |
Java EE SDK Runs Seam
Posted by rogerk on April 28, 2006 at 11:30 AM | Comments (6)
Seam-GlassFish
I am happy to report that Seam
(the JBoss application framework that unifies JSF and EJB 3.0) runs on GlassFish, the Open Source
Application Server from which the Java EE SDK is built. This
required some modifications and rebuilding of Seam source code, mainly
because of the repackaging of EJB classes in accordance to the latest
EJB specification implementation. JBoss is making the required
changes, but for those of you who can't wait, I'll describe those
changes and setup necessary to get a Seam application up and running on
GlassFish. Also, I'd like to point out, that these instructions
are for the Seam 1.0beta2 release. Recently JBoss has released a
later version, but the interceptor related packaging changes are not
there. First, let's install the
patches and get the Seam Booking application up and running.
Prerequisites:
- A working build environment with ant,
at least JDK 5,
and GlassFish
(build 43 or later).
- For this application, you will also need to make sure you have
the compatable Hibernate libraries with GlassFish:
- Download and install Hibernate3
3.2cr1 or later.
- Download and install Hibernate
EntityManager 3.1 beta7 or later.
- 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-patch.zip
.
- Go to the jboss-seam-1.0beta2 directory and unzip
seam-core-patch.zip and seam-booking-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 and run 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
- Visit localhost:8080/seam-booking
Now, here is an explanation of changed modules. The current JBoss
Seam codebase is not up to date with the latest EJB specification (and
implementation - as in GlassFish). Seam classes still reference
EJB interceptor related classes in the javax.ejb package, but these now
exist in the javax.interceptor
package. JBoss will be updating their source, but I am not clear
on when that will happen.
Core classes:
src/main/org/jboss/seam/Component.java
src/main/org/jboss/seam/ejb/SeamInterceptor.java
src/main/org/jboss/seam/interceptors/BijectionInterceptor.java
src/main/org/jboss/seam/interceptors/BusinessProcessInterceptor.java
src/main/org/jboss/seam/interceptors/ConversationInterceptor.java
src/main/org/jboss/seam/interceptors/Interceptor.java
src/main/org/jboss/seam/interceptors/JavaBeanInterceptor.java
src/main/org/jboss/seam/interceptors/OutcomeInterceptor.java
src/main/org/jboss/seam/interceptors/RemoveInterceptor.java
src/main/org/jboss/seam/interceptors/RollbackInterceptor.java
src/main/org/jboss/seam/interceptors/SeamInvocationContext.java
src/main/org/jboss/seam/interceptors/ValidationInterceptor.java
----> interceptor package changes
described above
src/main/org/jboss/seam/jsf/SeamPhaseListener.java
----> moved initilialization of
SeamVariableResolver, SeamNavigationHandler, SeamStateManager to
faces-config.xml, so they get created at startup.
src/main/org/jboss/seam/jsf/SeamStateManager.java
----> new class taken from
StateManagerInterceptor class in SeamPhaseListener
src/main/META-INF/faces-config.xml
----> defines SeamVariableResolver,
SeamNavigationHandler, SeamStateManager
---->
modified component definition for HtmlQueryTable
src/main/org/jboss/seam/mock/MockServletContext.java
----> stubbed in public String
getContextPath() method
Booking Application Modules:
examples/booking/resources/import.sql
examples/booking/resources/META-INF/persistence.xml
----> updated for application with
GlassFish
examples/booking/resources/WEB-INF/web.xml
----> reference 2.5 schema, etc..
----> modified JNDI name pattern for EJB lookups
----> disabled MyFaces StartupServletContextListener (not compatable
with JSF 1.2)
----> added <ejb-local-ref> elements for EJB modules
examples/booking/src/org/jboss/seam/example/booking/BookingListAction.java
examples/booking/src/org/jboss/seam/example/booking/ChangePasswordAction.java
examples/booking/src/org/jboss/seam/example/booking/HotelBookingAction.java
examples/booking/src/org/jboss/seam/example/booking/LoggedInInterceptor.java
examples/booking/src/org/jboss/seam/example/booking/LoggedIn.java
examples/booking/src/org/jboss/seam/example/booking/LoginAction.java
examples/booking/src/org/jboss/seam/example/booking/LogoutAction.java
examples/booking/src/org/jboss/seam/example/booking/RegisterAction.java
----> interceptor package changes described above
examples/booking/src/org/jboss/seam/example/booking/User.java
----> create "Users" table and
reference it as "user" (User is reserved in javaee5)
examples/booking/view/main.xhtml
examples/booking/view/template.xhtml
----> added missing JSF "form" tags
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Very good news ,
can you please specify , what changes are requierd if we use latest version of Seam , I mean seam 1 RC which is available in download section of seam in source forge ?
And , why we should use hibernate persistence ? we have glassfish persistence and i like to use that , is it possible ?
Thanks
Posted by: legolas_w on April 29, 2006 at 02:29 AM
-
Seam 1 RC was just released. I briefly looked at it - the interceptor changes are not there yet - so you would still need to apply part of this patch. The next step would be to get the latest version of Seam working - with perhaps glassfish persistence. Thanks for the comments.
Posted by: rogerk on May 01, 2006 at 07:14 AM
-
Even though cr2 is out, I figured I'd try this with beta 1, since the docs are done for me, and it should be close enough to actually learn the tool. When I install the booking demo (I'm deploying the .ear through the admin web app), the logs tell me that the application was not loaded. No other details. If I run the verifier on the .ear, I get a number of failures, all of which are classes not found. Here are the base packages:
org.jaxen (which I grabbed from the Hibernate distro)
org.jbpm
javax.portlet
org.logicalcobwebs
org.objectweb.asm.util.TraceClassVisitor (actual class)
What am I missing? I've retraced my steps, and I think I followed your instructions to the letter, but it's obviously not working for me. :)
jason
Posted by: jdlee on May 01, 2006 at 09:45 AM
-
What messages do you see in the log file?
Posted by: rogerk on May 01, 2006 at 10:49 AM
-
After what is likely very ugly hacking and poking, I've made some progress. Right now, when I deploy the ear, Glassfish is telling me
Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
java.lang.NoClassDefFoundError
The jar is available to the app server, in two places, actually: in the .war and in the server's lib directory.
Posted by: jdlee on May 01, 2006 at 12:24 PM
-
OK. I got it working. I started with a fresh Glassfish install to clean up any craziness I might have introduced, and downgraded from Hibernate EM beta 8 to beta 7. It appears that beta 8 adds a requirement for META-INF/orm.xml, which the booking demo does not have. I'm not sure where that requirement comes from, but until the demo is updated to work with beta 8 or later, you'll need to stick to beta 7. After doing that, everything worked as promised.
Thanks, Roger, for all your help!
jason
Posted by: jdlee on May 02, 2006 at 09:25 AM
|