Skip to main content

Running JBoss' Seam on GlassFish

Posted by bleonard on June 20, 2006 at 3:07 PM PDT

My previous blog entries document how to incorporate Seam into an existing JSF / EJB 3.0 application running on JBoss. In this entry, I'm going to run that application on GlassFish. Seam has changed quite a bit in the short time period since those entries were written, so I'll provide for you a working Seam application to start. Note, in order to run Seam on GlassFish, we will need several libraries from JBoss, which is why we are also installing the JBoss server. This blog will show you the exact changes necessary in order to move a Seam application from JBoss to GlassFish.

Getting Started
  • Download and install a daily build of NetBeans 5.5. The 5.5 Beta has a taglib packaging bug which has since been fixed. For this blog I'm using the June 19th build.
  • Download and extract JBoss Seam 1.0.1 GA
  • Download and install JEMS 1.2.0. BETA1. The JEMS installer includes JBoss AS 4.0.4GA and EJB3 CR8, both of which are needed to work with Seam 1.0.1 GA. Be sure to select the ejb3 profile during installation.
  • Download GlassFish v1 (Milestone 7). I'll provide installation instructions in a separate step below.
  • Download and extract the Registration application.
Step 1: Preparation

In this first step, we'll set up the environment so that our Seam application successfully runs on JBoss.

Add the JBoss Server to NetBeans

  1. Switch to the Runtime tab and right-click the Servers node to add a server.

  2. Select JBoss Application Server 4 from the Server drop down list. Change the name to JBoss Application Server 4.0.4.

  3. Complete the Add Server wizard.
  4. Right-click the new JBoss server node and choose Start:

Create the Seam Class Libraries

The Registration Project that we'll open in the next step references a couple of libraries called JBossSeam and JBossSeamUI, which we'll now create using the 1.0.1 GA of Seam.


  1. Open the Library Manager (Tools menu) and create a new class library called JBossSeam.
  2. Set the Classpath to jboss-seam.jar.
  3. Set the Sources to the JBoss Seam src\main directory.
  4. Set the Javadoc to the JBoss Seam doc directory.


  1. Create another new class library called JBossSeamUI.
  2. Set the Classpath to jboss-seam-ui.jar.
  3. Set the Sources to the JBoss Seam src\ui directory.
  4. Set the Javadoc to the JBoss Seam doc directory.

These libraries are now available for use by any project.

Open the Registration Project

The Registration application is a NetBeans Enterprise Application Project, which is actually comprised of 3 projects: Registration, Registration-EJBModule and Registration-WebModule. Registraiton-EJBModule and Registration-WebModule are J2EE Modules of the Registration project. Registration-EJBModule generates the EJB jar file. Registration-WebModule generates the war file and Registration generates the ear file which contains the jar and war.

  1. Open the Registration project.
    The Enterprise Application Project stores the absolute location to its J2EE Modules. So, unless you extracted your project to the exact same location as me, you will see this dialog when you open the project.

  2. Click Close. The Registration project will be in bold red.
  3. Right click the project and select Resolve Reference Problems from the context menu.

  4. Use the Resolve Reference Problems dialog to map each module to its project, which you'll find are subdirectories beneath the Registration directory.

  5. After the references are resolved, right-click the Registration project and select Open Required Projects (now that the dependencies are correct, these dependent projects will always open for you).

  6. You'll notice the Registration-WebModule also has a reference problem, as it references the Registration-EJBModule. Use the same steps to correct the reference.

Test Run the Registration Project

  1. Press F6 to run the project. This will build, package, deploy, start JBoss and launch the application in a browser for you.

This is a fully functional Seam application running on JBoss. We'll now take the required steps to run it on GlassFish.

Install GlassFish

  1. Stop JBoss (both GlassFish and JBoss like to use port 8080)
  2. Open a command prompt
  3. CD to the directory where you downloaded GlassFish
  4. Run: java -Xmx256m -jar glassfish-installer-9.0-b48.jar
  5. cd glassfish
  6. Run: ant -f setup.xml

Add the GlassFish Server to NetBeans

  1. Switch to the Runtime tab and right-click the Servers node to add a server.
  2. Select Sun Java System Application Server from the Server drop down list. Change the name to GlassFish (The Sun Java System Application Server is Sun's distribution of GlassFish).

  3. Click Next. For the Platform Location, browse to the same glassfish directory from which you ran the ant script above and click Next.
  4. Enter adminadmin as the Admin Password and click Finish.
  5. Right-click the new GlassFish server node and choose Start.
Step 2: Making the Switch

Ok, now we are ready to document the changes required to run our JBoss Seam application on GlassFish. It's really a matter of updating the persistence unit, updating the web.xml and adding some additional JBoss libraries.

Switch the Runtime Server to GlassFish

  1. Right-click the Registration project and choose Properties.
  2. Select the Run category and change the Server from JBoss to GlassFish.
  3. Repeat this step for both the EJB and Web module projects.

Update the Persistence Unit

We'll update the persistence unit to use the persistence manager (TopLink) and database (Java DB) bundled with GlassFish.

  1. Delete the existing persistence.xml (Registration-EJBModule > Configuration Files).
  2. Right-click the Registration-EJBModule project and choose New > File/Folder.
  3. Select Persistence Unit from the Persistence Category.
  4. Change the Persistence Unit Name to default. The Persistence Provider should be TopLink, the Data Source should be jdbc/sample and the Table Generation Strategy should be Create:

Add Seam Dependant Libraries

Unfortunately, Seam is dependant on a number of libraries that ship with JBoss. I've raised this issue on the Seam forum. For now, we'll create a third class library and add it to our Registration project.

  1. Create another new class library called JBossSeamGF.
  2. Set the Classpath to commons-logging.jar and dom4j.jar which are found in the lib directory of your JBoss installation.
  3. Also add cglib.jar, hibernate-annotations.jar and hibernate3.jar which are found in the server\default\lib directory of your JBoss installation.
  4. Right-click the Libraries node of the Registration-EJBModule and add the JBossSeamGF library.

Clean Up web.xml

  1. Update the org.jboss.seam.core.init.jndiPattern to java:comp/env/registration/#{ejbName}/local.
  2. Delete the org.apache.myfaces.webapp.StartupServletContextListener.
  3. Add a reference to the RegisterAction EJB:


Run the Registration Project on GlassFish

That's it. Your application should now run on GlassFish.

  1. Press F6 to run the project:

    Here's the completed application converted to GlassFish. You'll have to reslove the same reference problems as you did above.
Related Topics >>