Seam 2.2.2.Final with Apache Tomcat 7.0

From last three days, I was messing up with Seam 2.2, trying to get it work with Tomcat 7.

Seam can work with JBoss AS, GlassFish & other AS. but Tomcat being just a Servlet Container has many drawbacks.

My Setup:

  • JDK 1.7.0
  • Apache Tomcat 7.0
  • eclipse indigo (JBossTools  for indigo installed)
  • Seam 2.2.2.Final
  • JPA with Transaction type: RESOURCE_LOCAL (an alternative to default JTA)
  • Database : MySql 5.1 with MySql J/Connection 5.1

From Seam 2.2.2Final distribution, locate LIB folder, copy following JARs to tomcat 7/LIB folder:

Hibernate dependencies:

  1. annotations-api.jar
  2. cglib-nodep.jar
  3. commons-collections.jar
  4. commons-logging.jar
  5. dom4j.jar
  6. javassist.jar


  1. hibernate-core.jar
  2. hibernate-annotations.jar
  3. hibernate-commons-annotations.jar
  4. hibernate-entitymanager.jar
  5. hibernate-search.jar
  6. lucene.jar
  7. hibernate-validator.jar

JSF 1.2:

  1. jsf-api.jar
  2. jsf-impl.jar
  3. jsf-facelets.jar


  1. jta.jar
  2. persistence-api.jar
  3. ejb3-persistence.jar (used by hibernate+JPA)

Logging for Hibernate and Seam:

  1. log4j.jar
  2. slf4j-api.jar
  3. slf4j-log4j12.jar
  4. (for debug messages)


  • drools-api.jar
  • drools-compiler.jar
  • drools-core.jar
  • drools-decisiontables.jar
  • drools-templates.jar

Now,after adding all these JAR’s your tomcat, your tomcat is ready to host seam 2.2 application.

  1. Create new Seam Web Project in eclipse
    Step 1
  2. Use Apache Tomcat 7.0 as Application Server (add if not done already)
  3. use selected configuration (which includes Seam 2.2)
  4. JSF Configuration: Disable Library configuration (We have added all JSF 1.2 Jars to our Tomcat)
  5. Use Seam Runtime : <<select folder where  you have extracted Seam 2.2.2>>
  6. Use Database connection New MSQL (Click on “New” button to create new connection, make sure that you have already created one EMPTY database in MySQL with name TestDB2)
  7. Click Finish to end project creation.
  8. Now, open “Package Explorer” 
  9. Inside package explorer … now you will get “WebContent” Folder which contains another one “META-INF” folder. I will now create context.xml inside this folder. This context will be deployed at the time of application deployment, which will result in deploying a (local) javax.sql.DataSource to Tomcat for current web application.
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/TestApp15" docBase="TestApp15" crossContext="true">
        <Resource name="MyData" auth="Container" 
            username="root" password="mahendra" 
  10. Now, there is another META-INF inside src/main with one “persistence.xml”. make few changes in it:
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Persistence deployment descriptor for dev profile -->
    <persistence xmlns="" 
       <persistence-unit name="TestApp15PU" transaction-type="RESOURCE_LOCAL">
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
             <property name="" value="create-drop"/>
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="hibernate.default_catalog" value="TestDB2"/>
  11. We are using NON JTA data source instead of default JTA, we are not using any Caching provider from Hibernate so remove Caching provider if any.
  12. From WebContents/WEB-INF folder, open “components.xml”, make following changes:
    <?xml version="1.0" encoding="UTF-8"?>
    <components xmlns=""
            <core:init />
       <core:manager concurrent-request-timeout="500"
       <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
       <web:hot-deploy-filter url-pattern="*.seam"/>
       <!-- If you are still using JBoss 4, uncomment this to have your PU started -->
    <!--   <persistence:entity-manager-factory name="entityManagerFactory"-->
    <!--                      persistence-unit-name="TestApp15"/>-->
       <!-- If you are still using JBoss 4, uncomment this to have the entityManagerFactory ysed -->
    <!--   <persistence:managed-persistence-context name="entityManager" auto-create="true"-->
    <!--                          entity-manager-factory="#{entityManagerFactory}"/>-->
            <tx:entity-transaction entity-manager="#{entityManager}" auto-create="true"/>
       <drools:rule-base name="securityRules">
       <security:rule-based-permission-resolver security-rules="#{securityRules}"/>
       <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
       <event type="">
          <action execute="#{redirect.captureCurrentView}"/>
       <event type="">
          <action execute="#{redirect.returnToCapturedView}"/>
       <mail:mail-session host="localhost" port="25"/>
       <!-- For use with jBPM pageflow or process management -->
  13. Run application in Tomcat.

NOTE: You may download Video screen cast for the above demo at my box account

3 comments on “Seam 2.2.2.Final with Apache Tomcat 7.0

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s