SeamFramework.orgCommunity Documentation

Chapter 37. Seam on IBM's Websphere

37.1. Websphere environment and deployment information
37.1.1. Installation versions and tips
37.1.2. Required custom properties
37.2. The jee5/booking example
37.2.1. Configuration file changes
37.2.2. Building the jee5/booking example
37.2.3. Deploying the application to Websphere
37.3. The jpa booking example
37.3.1. Building the jpa example
37.3.2. Deploying the jpa example
37.3.3. Whats different for Websphere 6.1
37.4. Deploying an application created using seam-gen on Websphere
37.4.1. Running seam-gen Setup
37.4.2. Changes needed for deployment to Websphere

Websphere 6.1.x is IBM's application server offering. The latest release is which does not have EJB3 or JEE5 support. There is a recently released (Nov 07) EJB3 feature pack which provides some support for EJB3 and JPA. Currently there is no true JEE5 offering from IBM. This causes some issues with Seam integration with applications that use EJB3.

First we will go over some basic information about the Websphere environment that we used for these examples. After a good deal of research and work we were able to get EJB3 applications to function correctly. We will go over the details of those steps with the jee5 example. We will also deploy the the JPA example application.

Websphere is a commercial product and so we will not discuss the details of its installation other than to say follow the directions provided by your particular installation type and license. This section will detail the exact server versions used, installation tips, and some custom properties that are needed for all of the examples.

All of the examples and information in this chapter are based on the the latest version of Websphere at the time of this writing.

The EJB3 feature pack that we installed came with the patch version of Websphere. Installing the feature pack does not ensure that your server will have the proper environment for EJB3 applications. Be sure that as part of the installation of the feature pack you follow the instructions to create a new server profile with the EJB3 feature pack enabled, or augment one of your existing ones. This can also be done after the installation by running the profile managment tool.

A note about restarting the server

There are times that restarting the server will be required after deploying or changes the examples in this chapter. Its does not seem like every change requires a restart. If you get errors or exceptions after modifing a property or deploying an application try to restart the server.

There are a couple of Websphere custom properties that are required for Seam integration. These properties are not needed specifically for Seam, but work around some issues with Websphere. These are set following the instructions here : Setting web container custom properties

  • prependSlashToResource = "true" — This solves a fairly common issue with Websphere where applications are not using a leading "/" when attempting to access resources. If this is not set then a will be thrown. With this property set you will still see warnings, but the resources will be retrieved as expected.

  • = "true" — This solves an issue with Websphere where it throws a FileNotFoundException when a web application attempts to access a file resource that does not actually exist on disk. This is a common practice in modern web applications where filters or servlets are used to process resource requests like these. This issue manifests itself as failures to retrieve JavaScript, CSS, images, etc... when requesting a web page.

The jee5/booking example is based on the Hotel Booking example (which runs on JBoss AS). Out of the box it is designed to run on Glassfish, but with the steps below it can be deployed to Websphere. It is located in the $SEAM_DIST/examples/jee5/booking directory.

As stated before the EJB3 feature pack does not provide a full jee5 implementation. This means that there are some tricks to getting an application deployed and functioning.

Below are the configuration file changes that are need to the base example.


We need to change the way that we look up EJBs for Websphere. We need to remove the /local from the end of the jndi-pattern attribute. It should look like this:

<core:init jndi-pattern="java:comp/env/jboss-seam-jee5/#{ejbName}" debug="true"/>

This is the first place that we notice an unexpected change because this is not full jee5 implementation.

Websphere does not support Servlet 2.5, it requires Servlet 2.4. For this change we need to adjust the top of the web.xml file to look like the following:

<xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 

Next, we have to make some changes to the EJB references in the web.xml. These changes are what will allow Websphere to bind the EJB2 references in the web module to the the actual EJB3 beans in the EAR module. Replace all of the ejb-local-refs when the values below.

  <!-- JEE5 EJB3 names -->
    <local> of the examples and informaearching</local> 

The important change is that there is an empty local-home element for each EJB. This tells Websphere to make the correct bindings between the web module and the EJB3 beans. The ejb-link element is simply not used.

Note also that EjbSynchronizations is a built-in Seam EJB and not part of the Hotel Booking example. This means that if your application's components.xml specifies transaction:ejb-transaction , then you must include:


in your web.xml. If you don't include it, you'll get the following error:

Name comp/env/myapp/EjbSynchronizations not found in context java:

For this example we will be using the default datasource that comes with Websphere. To do this change the jta-data-source element:


Then we need to adjust some of the hibernate properties. First comment out the Glassfish properties. Next you need to add/change the properties:

<!--<property name="hibernate.transaction.flush_before_completion" value="true"/>-->
<property name="hibernate.cache.provider_class" 
<property name="hibernate.dialect" value="GlassfishDerbyDialect"/>
<property name="hibernate.transaction.manager_lookup_class" 


You will need to get the GlassfishDerbyDialect.class and copy it into the /resources directory. The class exists in the JPA example and can be copied using the command below assuming you are in jee5/booking directory:

cp ../../jpa/resources-websphere61/WEB-INF/classes/GlassfishDerbyDialect.class

This class will be put into the jboss-seam-jee5.jar file using changes to the build.xml discussed later.


This file must also be copied from the JPA example because either the Derby DB or the dialect does not support changes to the ID column. The files are identical except for the column difference. Use the following command to make the copy

cp ../../jpa/resources-websphere61/import.sql ./resources

In order to get the changes we have made into our application we need to make some changes to the build.xml. There are also some additional jars that are required by our application in order to work with Websphere. This section will cover what changes are needed to the build.xml.

So now we have everything we need in place. All that is left is to deploy it - just a few steps more.

For this we will use Websphere's administration console. As before there are some tricks and tips that must be followed.

The steps below are for the Websphere version stated above, yours may be slightly different.

  1. Log in to the administration console


  2. Access the Enterprise Application menu option under the Applications top menu.

  3. At the top of the Enterprise Application table select Install. Below are installation wizard pages and what needs to done on each:

  4. Now that we have our application installed we need to make some adjustments to it before we can start it:

  5. To start the application return to the Enterprise Applications table and select our application in the list. Then choose the Start button at the top of the table.

  6. You can now access the application at http://localhost:9080/seam-jee5/ .

Thankfully getting the jpa example to work is much easier than the jee5 example. This is the Hotel Booking example implemented in Seam POJOs and using Hibernate JPA with JPA transactions. It does not require EJB3 support to run.

The example already has a breakout of configurations and build scripts for many of the common containers including Websphere.

First thing we are going to do is build and deploy that example. Then we'll go over some key changes that we needed.

This is similar to the jee5 example at Section 37.2.3, “Deploying the application to Websphere”, but without so many steps.

  • From the Enterprise Applications table select the Install button.

    • Preparing for the application installation

      • Browse to the examples/jpa/dist-websphere61/jboss-seam-jpa.war file using the file upload widget.

      • In the Context root text box enter jboss-seam-jpa.

      • Select the Next button.

    • Select the Next button for the next three pages, no changes are needed.

    • Summary page

      • Review the settings if you wish and select the Finish button to install the application. When installation finished select the Save link and you will be returned to the Enterprise Applications table.

  • As with the jee5 example there are some class loader changes needed before we start the application. Follow the instructions at installation adjustments for jee5 example but exchange jboss-seam-jpa for Seam Booking.

  • Finally start the application by selecting it in the Enterprise Applications table and clicking the Start button.

  • You can now access the application at the http://localhost:9080/jboss-seam-jpa/index.html.

The differences between the JPA examples that deploys to JBoss 4.2 and Websphere 6.1 are mostly expected; library and configuration file changes.

seam-gen is a very useful tool for developers to quickly get an application up and running, and provides a foundation to add your own functionality. Out of box seam-gen will produce applications configured to run on JBoss AS. These instructions will show the steps needed to get it to run on Websphere. As stated above in Section 37.2, “ The jee5/booking example ” there are some tricky changes needed to get an EJB3 application running. This section will take you through the exact steps.

The first step is setting up seam-gen to construct the base project. There are several choices made below, specifically the datasource and hibernate values that we will adjust once the project is created.

./seam setup
Buildfile: build.xml


     [echo] Welcome to seam-gen :-)
    [input] Enter your Java project workspace (the directory that contains your 
Seam projects) [C:/Projects] [C:/Projects]
    [input] Enter your JBoss home directory [C:/Program Files/jboss-4.2.2.GA] 
[C:/Program Files/jboss-4.2.2.GA]
    [input] Enter the project name [myproject] [myproject]
     [echo] Accepted project name as: websphere_example
    [input] Do you want to use ICEFaces instead of RichFaces [n] (y, [n], )

    [input] skipping input as property has already been set.
    [input] Select a RichFaces skin [blueSky] ([blueSky], classic, ruby, wine, 
deepMarine, emeraldTown, sakura, DEFAULT)

    [input] Is this project deployed as an EAR (with EJB components) or a WAR 
(with no EJB support) [ear]  ([ear], war, )

    [input] Enter the Java package name for your session beans [org.jboss.seam.
tutorial.websphere.action] [org.jboss.seam.tutorial.websphere.action]
    [input] Enter the Java package name for your entity beans [org.jboss.seam.
tutorial.websphere.model] [org.jboss.seam.tutorial.websphere.model]
    [input] Enter the Java package name for your test cases [org.jboss.seam.
tutorial.websphere.action.test] [org.jboss.seam.tutorial.websphere.action.test]
    [input] What kind of database are you using? [hsql]  ([hsql], mysql, oracle,
 postgres, mssql, db2, sybase, enterprisedb, h2)

    [input] Enter the Hibernate dialect for your database [org.hibernate.
dialect.HSQLDialect] [org.hibernate.dialect.HSQLDialect]

    [input] Enter the filesystem path to the JDBC driver jar [lib/hsqldb.jar] 

    [input] Enter JDBC driver class for your database [org.hsqldb.jdbcDriver] 

    [input] Enter the JDBC URL for your database [jdbc:hsqldb:.] 

    [input] Enter database username [sa] [sa]

    [input] Enter database password [] []

    [input] Enter the database schema name (it is OK to leave this blank) [] []

    [input] Enter the database catalog name (it is OK to leave this blank) [] []

    [input] Are you working with tables that already exist in the database? [n]
  (y, [n], )

    [input] Do you want to drop and recreate the database tables and data in 
import.sql each time you deploy? [n]  (y, [n], )

[propertyfile] Creating new property file: 
     [echo] Installing JDBC driver jar to JBoss server
     [copy] Copying 1 file to /home/jbalunas/jboss/jboss-4.2.2.GA/server/default/lib
     [echo] Type 'seam create-project' to create the new project

Total time: 3 minutes 5 seconds

Type ./seam new-project to create your project and cd /home/jbalunas/workspace/websphere_example to the newly created structure.

We now need to make some changes to the generated project.


As with other examples we need to include this class for DB support. It can be copied from the jpa example into the websphere_example/resources directory.

cp $SEAM/examples/jpa/resources-websphere61/WEB-INF/classes/GlassfishDerbyDialect.class


You can delete this file as we aren't deploying to JBoss AS ( jboss-app.xml is used to enable classloading isolation in JBoss AS)


You can delete these file as we aren't deploying to JBoss AS (these files define datasources in JBoss AS, we are using Websphere's default datasource)

  • Enable container managed transaction integration - add the <transaction:ejb-transaction /> component, and it's namespace declaration xmlns:transaction=""

  • Alter the jndi-pattern to java:comp/env/websphere_example/#{ejbName}

  • We do not need managed-persistence-context for this example and so can delete its entry.

    <persistence:managed-persistence-context name="entityManager"

Websphere does not support Servlet 2.5, it required Servlet 2.4. For this change we need to adjust the top of the web.xml file to look like the following:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 

As with the jee5/booking example we need to add EJB references to the web.xml. These references require the empty local-home to flag them for Websphere to perform the proper binding.


This application has similar requirements as the jee5/booking example.