Skip navigation

Today I will guide you through migration path for Dvdstore example from Seam 2.2.2.Final distribution.

What is interesting on Dvdstore example? It presents quite complex set of Seam features including jbpm-jpdl and Hibernate Search integration.

Data source preparation

If you don't want to use default ExampleDS and change JNDI in persistence.xml, you have to create the new data source under JNDI java:/dvdstoreDatasource.

Simply run:

bin/ -c \
--command="add-data-source --jndi-name=java:/dvdstoreDatasource --connection-url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 --username=sa --password=sa --pool-name=DefaultDS_pool --driver-name=h2"


In comparing to JBoss AS 7.0.2.Final, if you use 7.1.0.x you need to do additional step to enable data source, because it is created disabled:

bin/ -c --command="/subsystem=datasources/data-source="java\:\/dvdstoreDatasource":enable"


You can check the creation of datasource in server log or on console:

INFO  [] (MSC service thread 1-3) Bound data source [java:/dvdstoreDatasource]

Enterprise package migration - dvdstore EAR

Main target of EAR configuration is to set up correctly supported runtime libraries - these are JSF 1.2, Hibernate JPA. Seam 2.2.2.Final has got integration with JSF 1.2, JPA 1.0. On the other side JBoss AS7 has got JSF 2.1 and JPA 2.0 by default. These specifications are not drop in replacements and therefore dvdstore configurations require some changes to disable defaults and enable supported Seam application. This type of configurations can be managed in more than one way.

I will show you the powerful way - which are placed in jboss-deployment-structure.xml file. This is not new, you already could see it in my previous blogs about Booking nad JPA examples migrations. But now jboss-deployment-structure.xml file have one extra sub-deployment element section in comparison to Booking jboss-deployment-structure.xml file.

Insert the following content to jboss-seam-dvdstore.ear/META-INF/jboss-deployment-structure.xml:

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
      <module name="org.hibernate" slot="main"/>
          <module name="org.apache.log4j" export="true"/>
          <module name="org.dom4j" export="true"/>
          <module name="org.apache.commons.logging" export="true"/>
          <module name="org.apache.commons.collections" export="true"/>
          <module name="javax.faces.api" slot="1.2" export="true"/>
          <module name="com.sun.jsf-impl" slot="1.2" export="true"/>
          <module name="org.slf4j" export="true"/>
  <sub-deployment name="jboss-seam-dvdstore.war"> 
          <module name="javax.faces.api" slot="main"/>
          <module name="com.sun.jsf-impl" slot="main"/>
          <module name="org.hibernate" slot="main"/>
          <module name="javax.faces.api" slot="1.2"/>
          <module name="com.sun.jsf-impl" slot="1.2"/>
  <sub-deployment name="jboss-seam-dvdstore.jar">
      <module name="org.hibernate" slot="main"/>


Little explanation to all lines above:

  1. Deployment element disables default JPA 2 provider in main slot (see exclusion of org.hibernate), because we won't use default Hibernate from AS7, but bundled Hibernate 3.3.1 in application lib directory.
  2. Deployment element for EAR also turns on all necessary dependencies and JSF 1.2 support. Notice additional attribute export, which says that a module be available also for WAR(s) and JAR(s).
  3. Sub-deployment for WAR jboss-seam-dvdstore.war disables default JSF 2 and choosed JSF 1.2 alternative and again disabling Hibernate 4 slot.
  4. Sub-deployment for EJB jar jboss-seam-dvdstore.jar disables  default main Hibernate 4 slot too.

Final step is to add all required additional jars for using known supported integraitons with Seam 2.2 It means bundling hibernate jars from Seam 2.2.2.Final distribution and its direct runtime dependencies:

  • hibernate-core.jar
  • hibernate-validator.jar
  • hibernate-entitymanager.jar
  • bsh.jar
  • hibernate-annotations.jar
  • antlr.jar

EJB archive migration - JAR

Main point of the following steps are to be properly bundled Hibernate 3 libraries and usage of dependencies which are originally integrated with Seam.

Main points of using JPA provider in AS7 are covered in in section "Packaging the Hibernate 3.5 or greater 3.x JPA persistence provider with your application". But there are some limitations of hibernate integration older than 3.5 version.

For instance import/export database schema with bundled Hibernate 3.3.x doesn't work out of the box - it requires additional class mapping. Next change is caused by switching of default database driver for data source from HSQLDB to H2 database and little incompatibility changes in Varchar support. This requires a small change in com.jboss.dvd.seam.Product class to extends length of description field to e.g 9000. Because otherwise you will see exceptions like this:

Caused by: org.h2.jdbc.JdbcSQLException: Value too long for column "DESCRIPTION VARCHAR(1024)"

Changes in jboss-seam-dvdstore.jar/META-INF/persistence.xml are following:

  • We need to choose proper JPA provider for bundled Hibernate 3.3 library:

    <property name="" value="hibernate3-bundled" />

  • Adding mapping for entity classes due not possibility to automatically entities scan for bundled Hibernate 3.3:











  • We also need to change value of transaction.manager_lookup_class property to in hibernate.cfg.xml. This file is required for JBPM-JPDL database configuration for business process mapping.
<property name="transaction.manager_lookup_class" value="" />
  • Last step in EJB jar migration is, we need all xml file originally placed at EAR root to be moved into EJB jar root:
    • checkout.jpdl.xml,
    • jbpm.cfg.xml,
    • hibernate.cfg.xml,
    • newuser.jpdl.xml,
    • ordermanagement1.jpdl.xml,
    • ordermanagement2.jpdl.xml,
    • ordermanagement3.jpdl.xml.

Reason for that moving files is that EAR root directory is not in classloader path anymore n JBoss AS7.

Web application packaging in WAR

Configuration in jboss-seam-dvdstore.war should be changed in way of customizing  new format of JNDI to EJBs, first adding two lines for Seam EJBs EjbSynchronizations and TimerServiceDispatcher, second set all other dvdstore application based EJBs to JNDI pattern - this is the same as before, you need only change the JNDI pattern in jboss-seam-dvdstore.war/WEB-INF/components.xml from

<core:init debug="true" jndi-pattern="jboss-seam-dvdstore/#{ejbName}/local"/>


<core:init debug="true" jndi-pattern="java:app/jboss-seam-dvdstore.jar/#{ejbName}"/>


I will use this way, because it is proper for dvdstore application with many application session beans. So at the end of this change, you will have jboss-seam-dvdstore.war/WEB-INF/components.xml with these additional 2 lines under already existing <core:init/> line:


<core:init debug="true" jndi-pattern="java:app/jboss-seam-dvdstore.jar/#{ejbName}"/>
<component class="org.jboss.seam.transaction.EjbSynchronizations" jndi-name="java:app/jboss-seam/EjbSynchronizations"/>
<component class="org.jboss.seam.async.TimerServiceDispatcher" jndi-name="java:app/jboss-seam/TimerServiceDispatcher"/>


And that is all! Enjoy shopping of DVDs in JBoss AS7.


Focus on Seam 2.3.0

Posted by manarh Dec 4, 2011

Public probably noticed that Shane Bryzak (Seam3 project lead) published blog about Seam.Next transformation. This is Seam team reaction to  SoWhatsHappeningWithSeam blog responses.


While Seam core team is focusing on Seam.Next transformation I am still slowly progressing with Seam 2.3.0.Beta1. This is not changing!


So I would like to write about Seam 2.3.0 in development.


First of all JSF2 support, this is primary reason to do 2.3.0 release. Although it is late and still not fully finished, 2.3.0.Beta1 will be very soon on table. Right now you can try current 2.3.0-SNAPSHOT from JBoss snapshot Maven repository ( and report all issue you have with them.


Just use Seam maven artifacts in your project:














You can also see CI results on Jenkins which does deploying of snapshots to above mentioned repository.


I ask myself regularly if Seam community appreciates keeping old JSF 1.2 integration in Seam if there will be support of JSF 2 included. Could you help me with the answer?


Second target for 2.3.0 is a support of JBoss AS7 and enjoying speed and modularity of new JBoss AS 7 runtime. I think this is interesting also like JSF2 support, but it raises some tasks which weren't originally planned for 2.3.0 and hinders finishing of 2.3.0. It is connected with upgrade of Hibernate Core, Search and JBPM3 integration for top level view and also replacing of Seam integration testsuite which is based on very old JBoss Embedded beta3. I will defer some of that tasks to later beta2 or 2.4.


I hope that with regarding to all responses in forums, Seam community would like primary to have done JSF2 support and all other tasks are for now on other side of our/my focus. If you have different opinion(s), raise your hands and shout loudly ;-).

Filter Blog

By date:
By tag: