Deploying Formspider Middle Tier to Tomcat

It is possible to deploy Formspider middle tier to any JEE compliant container. This tutorial explains deploying Formspider to a Tomcat instance.

Deploying the Formspider WAR File

Open the Tomcat Web Application Manager from the browser (it should have a URL address similar to the following: http://localhost:8080/manager/html/). Navigate to the “Deploy” section at the end of the page and click the “Choose File” button from the “War file to deploy” section to select the Formspider war file from your local drive.

Deploying a new application


Press the “Deploy” button to complete the deployment of the war file to your Tomcat instance. Note that the name of the example war file used in this tutorial is “fs_demo.war”

Select archive


When the deployement completes, Tomcat automatically creates a new folder with the same name of your war file under the \[Tomcat Installation Path]\webapps folder.

Configuring the Database Connection

After the deployment is completed, it’s time to configure the database connection. There are two ways to define database connection parameters. You can either use “JDBC Resouces” or application web.xml parameters.

Connecting with JDBC Resources

There are two seperate ways to define database connection parameters. The first way is to define local connection parameters which can be used only by a single deployment. The second way is to define global connection parameters which can be used by all deployements existing in your Tomcat instance.

Defining Local Connection Parameters
  • If META-INF folder exists in the \[Tomcat Installation Path]\webapps\fs_demo folder, execute the following steps.
    • Find the fs_demo.xml under the \[Tomcat Installation Path]\conf\Catalina\localhost\ folder.
    • In the fs_demo.xml file, edit the “name”, “url”, “user” and “password” as the following:
      • set “name” to a value of your choice. You will use this value later on web.xml file of your deployment.
      • set “url” to JDBC URL of Formspider schema
      • set “user” to Formspider schema name
      • set “password” to Formspider schema password
    <Context>
       <WatchedResource>WEB-INF/web.xml</WatchedResource>
           <Resource auth="Container"
       		      driverClassName="oracle.jdbc.OracleDriver"
       		      factory="oracle.jdbc.pool.OracleDataSourceFactory"
       		      maxActive="20"
       		      maxIdle="10"
       		      maxWait="-1"
       		      name="jdbc/formspider_demo"
       		      password="FORMSPIDER"
       		      type="oracle.jdbc.pool.OracleDataSource"
       		      url="jdbc:oracle:thin:@localhost:1521:ora10g"
       		      user="FORMSPIDER">
          </Resource>
    </Context>
    


  • If the META-INF folder does not exist, do the following steps.
    • Create a folder called “META-INF” under the \[Tomcat Installation Path]\webapps\fs_demo folder, you can download the example META-INF folder from here.
    • Open context.xml file under the “META-INF” folder.
    • In the context.xml file, add a new resource and edit the “name”, “url”, “user” and “password” as the following:
      • set “name” to a value of your choice. You will use this value later on web.xml file of your deployment
      • set “url” to JDBC URL of Formspider schema
      • set “user” to Formspider schema name
      • set “password” to Formspider schema password

    The context.xml file should look like;

    <Context crossContext="true" reloadable="true">
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
    	<Resource auth="Container"
    		       driverClassName="oracle.jdbc.OracleDriver"
    		       factory="oracle.jdbc.pool.OracleDataSourceFactory"
    		       maxActive="20"
    		       maxIdle="10"
    		       maxWait="-1"
    		       name="jdbc/formspider_demo" password="FORMSPIDER"
    		       type="oracle.jdbc.pool.OracleDataSource"
    		       url="jdbc:oracle:thin:@localhost:1521:ora10g" user="FORMSPIDER">
           </Resource>
    </Context>
    


Resources are created. To enable Formspider deployment to use these resources find the Web.xml file of the newly deployed application. The Web.xml file path may differ depending on the application name and the Formspider WAR file name. Since the example war file name is fs_demo, the path of the Web.xml file should look something similar to this:

\[Tomcat Installation Path]\webapps\fs_demo\WEB-INF\

In the web.xml file, set “engineJdbcName” parameter to the value “jdbc/formspider_demo” that you have defined previously as the “name” value of your resource.

<context-param>
   <param-name>engineJdbcName</param-name>
   <param-value>jdbc/formspider_demo</param-value>
</context-param>


Defining Global Connection Parameters

Open context.xml file under the \[Tomcat Installation Path]\conf\ folder.

In the context.xml file, add a new resource and edit the “name”, “connectionCacheName”, “url”, “user” and “password” as the following:

  • set “name” to a value of your choice. You will use this value later on web.xml file of your deployment
  • set “connectionCacheName” to a value of your choice.
  • set “url” to JDBC URL of Formspider schema
  • set “user” to Formspider schema name
  • set “password” to Formspider schema password

The context.xml file should look like;

<Context crossContext="true" reloadable="true">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
	<Resource name="jdbc/formspider_demo"
		      auth="Container"
		      type="oracle.jdbc.pool.OracleDataSource"
		      driverClassName="oracle.jdbc.OracleDriver"
		      url="jdbc:oracle:thin:@localhost:1521:ora10g"
		      user="FORMSPIDER" password="FORMSPIDER"
		      factory="oracle.jdbc.pool.OracleDataSourceFactory"
		      scope="Shareable"
		      connectionCacheName="formspider_demo_cache"
		      connectionCachingEnabled="true"
		      connectionCacheProperties="{MinLimit=0, InitialLimit=0, ValidateConnection=true, MaxLimit=10, InactivityTimeout=1800, AbandonedConnectionTimeout=900, PropertyCheckInterval=60}">
	</Resource>
</Context>


Resources are created. To enable Formspider deployment to use these resources find the Web.xml file of the newly deployed application. The Web.xml file path may differ depending on the application name and the Formspider WAR file name. Since the example war file name is fs_demo, the path of the Web.xml file should look something similar to this:

\[Tomcat Installation Path]\webapps\fs_demo\WEB-INF\

In the web.xml file, set “engineJdbcName” parameter to the value “jdbc/formspider_demo” that you have defined previously as the “name” valueof your resource.

<context-param>
  <param-name>engineJdbcName</param-name>
  <param-value>jdbc/formspider_demo</param-value>
</context-param>


Connecting with Web.xml File Parameters

It is also possible to define the database connection parameters in the web.xml file without creating any resources in the Tomcat.This way is generally preferred in the development environment. Open web.xml file under the \[Tomcat Installation Path]\webapps\fs_demo\WEB-INF\ folder and edit the parameters, “engineSchemaURL”, “engineUsername”, “enginePassword” as the following:

  • set “engineSchemaURL” to JDBC URL of Formspider schema
  • set “engineUsername” to Formspider schema name
  • set “enginePassword” to Formspider schema password
<context-param>
  <param-name>engineSchemaURL</param-name>
  <param-value>jdbc:oracle:thin:@localhost:1521:ora10g</param-value>
</context-param>
<context-param>
  <param-name>engineUsername</param-name>
  <param-value>FORMSPIDER</param-value>
</context-param>
<context-param>
  <param-name>enginePassword</param-name>
  <param-value>FORMSPIDER</param-value>
</context-param>