Preparing and Deploying a TomEE server to execute SPADE

This article explains how to prepare and deploy a TomEE server so that is can be used by the "vanilla" version of SPADE.

Introduction

The current "vanilla" version of SPADE, nest-spade-war, can be run in a TomEE server. Therefore, in this article, you will learn how to prepare and deploy such a server. If you already have one running then you may be able to skip this section, though a brief glance at it may be useful to make sure your current server behaves as expected.


NOTE: These instructions are for a Tomee 1.7.1 installation on SLC 6.4. Other versions of the application and OS may need modifications to be successful.


Installation the Basic TomEE server

To start with, you can simply download the server and make sure it runs on your system. The following commands, using two windows on the same machine, do just that. In one window you should execute the following commands.

mkdir -p ~/server/apache-tomee-jaxrs-1.7.1/logs
touch ~/server/apache-tomee-jaxrs-1.7.1/logs/catalina.out
tail -1024f ~/server/apache-tomee-jaxrs-1.7.1/logs/catalina.out
In the other window the following commands will download and start the server.
mkdir -p ~/server/downloads
cd ~/server/downloads
wget http://mirrors.sonic.net/apache/tomee/tomee-1.7.1/apache-tomee-1.7.1-jaxrs.tar.gz
cd ..
tar zxvf downloads/apache-tomee-1.7.1-jaxrs.tar.gz
~/server/apache-tomee-jaxrs-1.7.1/bin/startup.sh

Once the server is running you will see in the first window the last line containing "INFO: Server startup", you can then shut it down by running the following in the second window.

~/server/apache-tomee-jaxrs-1.7.1/bin/shutdown.sh

Now that the basic server is installed you need to customize it for SPADE.

Adding the H2 database

SPADE uses a database to store information about the files it handles. Therefore the TomEE server needs to be modified to provide access to a suitable database. In order to run the example scenarios you can use H2 database. The commands below install the necessary file into the TomEE server


NOTE: For production you should use a production quality database as outlined here.


cd ~/server/downloads
wget http://www.h2database.com/h2-2014-04-05.zip
unzip h2-2014-04-05.zip h2/bin/h2-1.3.176.jar
mv h2/bin/h2-1.3.176.jar ~/server/apache-tomee-jaxrs-1.7.1/lib/
rmdir h2/bin
rmdir h2
cd -

In order for the TomEE server to know about the ExampleDS used by the "vanilla" version of SPADE the following commands should be run to modify its default configuration.

cd ~/server/apache-tomee-jaxrs-1.7.1
cp -rp conf/tomee.xml conf/tomee.xml.`date +%Y-%m-%d`
cat > patch_1.txt << EOF
*** conf/tomee.xml.2014-09-19 2014-09-12 05:12:41.000000000 -0700
--- conf/tomee.xml            2014-09-19 11:18:48.000000000 -0700
***************
*** 2,7 ****
--- 2,15 ----
  <tomee>
    <!-- see http://tomee.apache.org/containers-and-resources.html -->
  
+   <Resource id="ExampleDS" type="DataSource">
+     JdbcDriver          org.h2.Driver
+     JdbcUrl             jdbc:h2:~/spade/h2/spade
+     UserName            sa
+     Password            
+     JtaManaged          true
+   </Resource>
+ 
    <!-- activate next line to be able to deploy applications in apps -->
    <!-- <Deployments dir="apps" /> -->
  </tomee>
EOF
patch conf/tomee.xml patch_1.txt
rm patch_1.txt

The TomEE server is now ready to use the H2 database. However the H2 console application still needs to be deployed, and that is dealt with elsewhere.