In this page are described the steps to follow to deploy a web-application based on the smartweb framework on Tomcat Server.

Environment Details:

Needed Libraries (MVN Repository)

  • postgresql.jar
  • jta-1.0.1B.jar

Tomcat setup

The first thing to do is to add a new system property when you run tomcat.
It can be done by adding an argument when lunching tomcat from shell


This allows smartweb to use the appropriate configuration when running on tomcat server.

Add javax transaction library:

- Download javax transaction library jta-1.0.1B.jar and copy it to $TOMCAT/common/lib

DataSource setup

The following steps describe how to configure a jndi datasource if you are using PostgreSQL as database.

Configurations for other databases can be found at this link Tomcat JNDI Datasource HOW-TO

  1. Download PostgreSQL jdbc jar and copy it to $TOMCAT/common/lib
  2. Supposing that you want to configure a datasource accessible from any web-application deployed on tomcat you need to edit $TOMCAT/conf/context.xml adding the following code.
<Resource name="jdbc/DBname" auth="Container"
          type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
        username="username" password="password" maxActive="20" maxIdle="10" maxWait="-1"/>

The next step is to include a reference to this jdbc datasource in your application and so you have to edit the configuration file web.xml that can be found in the WEB-INF directory of your application ($TOMCAT/webapps/yourApp/WEB-INF)
You need to add the following code:

     <description>postgreSQL Datasource </description>

SmartWeb and Hibernate Configuration

The last step is to allow hibernate to access the datasource and so you need to edit smartweb.hcf.xml that can be found at ($TOMCAT/webapps/yourApp/WEB-INF/classes/META-INF).
The following code includes the basic property to include in your session factory configuration.
If you were using your application on JBoss and now you are editing your smartweb.hcf.xml be sure to remove any property referring to transaction like "transaction.factory_class" and "transaction.manager_lookup_class".

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "">
        <property name="show_sql">true</property>
        <property name="use_outer_join">true</property>
        <property name="batch_size">10</property>
        <property name="connection.datasource">java:/comp/env/jdbc/DBname</property> 
        <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

Now start Tomcat and your application should work.
This procedure was tested on Tomcat 5.5.27.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.