Take the “H2O” with you

There could be times that you need to access a message gateway, either for message transmission or for your software development needs. And it would be handy if it doesn't require any installation, but allows you to run on any machine, as long as JDK is available. This article will illustrates on how to prepare an "embedded" version of H2O, that runs on Jetty and HSQLDB, which you can bring it with you all the time.

Preparation

There are a couple of things we need to prepare before proceeding. First of all, let's create a folder which we will put everything together. Let's call it "/home/hermes2". Afterwards, you will need to have the webapp and plugin of H2O ready, you can either copy it from your installation or compile it from the sources. Download both Jetty and HSQLDB from their corresponding project website.

Jetty

Let's begins with the setting up of the application server. After you have downloaded Jetty from the project website, extract and copy the following files to the folder we defined above (/home/hermes2).

./etc
./lib
./webapps
./start.jar

Now, we need to restrict the access of the admin context path. Define the location of the properties file that store the username and password in /home/hermes2/etc/jetty.xml.

<Set name="UserRealms">
  <Array type="org.mortbay.jetty.security.UserRealm">
   <Item>
     <New class="org.mortbay.jetty.security.HashUserRealm">
      <Set name="name">Corvus Restricted Area</Set>
      <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
     </New>
    </Item>
   </Array>
</Set>

Define the username and password in realm.properties

admin: password,server-administrator,content-administrator,admin

HSQLDB

  1. Create the databases
  2. First of all, we need to create the 2 databases for ebMS and AS2. By defining the location and name of the database in the file "server.properties", the databases will be created by HSQLDB upon starting up.

    server.database.0=file:ebms
    
server.dbname.0=ebms
    
server.database.1=file:as2
    
server.dbname.1=as2

    We can then start the HSQLDB server by running the bash script,

    HSQLDB/demo/runServer.sh

  3. Setup SQLTool for SQL command execution
  4. After that, we need to create the table for each of the databases, we will use the SQLTool that comes along with HSQLDB in doing so. But before we can launch the application, we need to have some setting up, e.g. defining the username and password in accessing the databases. Create a file called sqltool.rc in user home directory and have the content illustrated as below.

    urlid ebms-sa
    
url jdbc:hsqldb:hsql://localhost/ebms
    
username sa
    
password
    urlid as2-sa
    
url jdbc:hsqldb:hsql://localhost/as2
    
username sa
    
password

  5. Create the tables for H2O
  6. java -jar hsqldb.jar ebms-sa ebms-hsql.sql
    
java jar hsqldb.jar as2-sa as2-hsql.sql
  7. Create user and grant access right
  8. java -jar hsqldb.jar ebms-sa
java -jar hsqldb.jar as2-sa

H2O Deployment

Copy the following folders to "/home/hermes2"

./plugins
./repository
./test
./logs

Modify the configuration files, basically to setup the path location and also the JDBC settings.

ebMS plugin
ebms.module.xml
log4j.properties.xml

AS2 plugin
as2.log.properties.xml
as2.module.core.xml

Corvus webapp
corvus.log.properties.xml
corvus.properties.xml

Main.admin plugin
admin.logger.xml

Time for testing

OK, now everything is ready and we can start Jetty and test.

Another step further - In-process mode for HSQLDB

But we can make the execution more seamless by having HSQLDB running as in-process mode. So that we don't need to have it started up explicitly.

Change the db connection setting in the file ebms.module.xml, as2.module.core.xml, partnership.module.core.xml (Loopback) as follows, restart and that's it.

<parameter name="url" value="jdbc:hsqldb:file:/home/hermes2/hsqldb/data/ebms"/>
<parameter name="url" value="jdbc:hsqldb:file:/home/hermes2/hsqldb/data/as2"/>

And yet, there's one issue that you need to be aware. It is now tied to a particular path (/home/hermes2), you will need to change the path of the various config file accordingly if you want to run it in other location.

Posted by Ronnie Kwok on 08/14 at 10:44 AM