Thursday, November 15, 2007

Seam 2.0 Portlet Example

Update - This post is deprecated. Please see this article about the new JBoss Portlet Bridge.

We are happy to announce a "technology preview" of the JBoss Portal Seam 2.0 portlet. Thanks to the hard work of the JSR-301 Expert Group we are able to integrate the Seam Booking Example via a portlet. However, there are still some limitations and RichFaces is currently not integrated.
For the booking example, we have replaced RichFaces components with standard JSF RI 1.2 components.
We made this example beyond easy to get up and running and it shouldn't take more than a few minutes to have it running locally on your machine.

  • Install latest version of Maven 2.x
  • Checkout the project using a subversion client from
  • I used a Mysql database for this demo. You can use any of the DBs that Jboss Portal supports but for the sake of following along with this tutorial, I recommend downloading and starting a Mysql instance on your local machine.

Local Setup
Once you have Mysql started, login to the mysql console as root and run the following:
create database jbossportal;

GRANT ALL PRIVILEGES ON jbossportal.* TO 'jbossportal'@'localhost' IDENTIFIED BY 'jbossportal';

That's it!

Now, navigate to the root of the SeamBookingPortlet application and run
mvn install

Once the build is finished and successful, navigate to SeamBookingPortlet/ear and run
mvn cargo:start

*Note - this will take a few minutes. This downloads JBoss AS 4.2.2.GA along with the core installation of JBoss Portal 2.6.2. The download was around 100MB, but I removed as much as possible and got it down to 40MB. Once this is finished and the server is started, do yourself (and our servers ;) a favor and copy the zip file from SeamBookingPortlet/ear/target/installs/ to somewhere outside of this directory (anywhere on your machine) and open the ear/pom.xml to point to your new local file location. This can be changed at the bottom of the pom.xml file.

Now you are ready to deploy the SeamBookingDemo ear to your running JBoss server. Open a new console window and navigate to the same directory you were in SeamBookingPortlet/ear and run
mvn cargo:deploy

After you see that the Seam application has deployed. Open a new window/tab and visit http://localhost:8080/portal. You should see the Seam Booking application in a portlet window.

This example uses the core installation of JBoss Portal 2.6.2, Seam 2.0 GA, and the JSR-301 Bridge from MyFaces. The code for the booking demo is unmodified and a direct port from the Seam cvs repository. The modifications made to the JBoss AS download are minimal. First, I installed the core JBoss Portal 2.6.2 ( How to install). Then I added the datasource files for both Seam Booking and Portal. Finally I added the mysql driver to the server lib folder. That is all the changes that were made from the 4.2.2 GA release (other than I deleted around 50MB of unneeded files for this demo).

Thanks to the JSR 301 specification it is now possible to make Seam applications work in a Portlet environment. The next challenge for us, is to get Rich Faces components working in Seam applications in the same Portlet environment.