Install Genesis II as a Windows Service

In order to install a Genesis II container as a Windows Service, we must use the Java Service Wrapper.It can also be installed as a unix daemon, but this how to will focus on Windows.
The instructions for both setups will be almost identical.

There are two ways to integrate the Java Service Wrapper for use with Genesis II.
One is to use the WrapperSimpleApp class to launch the container.The other is to create a class that implements WrapperListener. It is easier to implement the first method, but will be beneficial to use the second if possible.
Only the second implementation requires any Java coding.

Part 3 contains information for my JBoss version that prepares the host computer for use with GeniiNet.


Integration by JBoss

Getting started

Install Genesis II on your system. We are assuming for this tutorial that we will install Genesis II to C:\Genesis, and JBoss will be installed within that.
Configure Genesis II as necessary, such as editing security files and configuration properties.

Follow the directions for integrating the Wrapper with JBoss. I followed these directions for Windows and got the wrapper working perfectly. For the linux version, I had an issue with using the JBoss version that they did.

Editing wrapper.conf

Next, we must customize the wrapper.conf configuration file to meet Genesis II's needs. Essentially, we will be copying the information from Genesis II's runContainer.bat into the configuration file for the Java Service Wrapper.

Here are a list of all of the properties that need to be changed or added if they do not exist by default:

wrapper.working.dir=C:\Genesis
wrapper.java.classpath.2=\lib\tools.jar
wrapper.java.classpath.3=C:\Genesis\jboss-3.0.4\bin\run.jar
wrapper.java.classpath.4=C:\Genesis\ext\bouncycastle\bcprov-jdk15-133.jar
wrapper.java.classpath.5=C:\Genesis\lib\GenesisII-security.jar
wrapper.java.classpath.6=C:\Genesis\lib\morgan-utilities.jar
wrapper.java.classpath.7=C:\Genesis\lib
wrapper.java.classpath.8=C:\Genesis\security
wrapper.java.library.path.1=C:\Genesis\jboss-3.0.4\lib
wrapper.java.library.path.2=C:\Genesis\jni-lib
wrapper.java.additional.1=-Dprogram.name=run.bat
wrapper.java.additional.2=-Dlog4j.configuration=genesisII.log4j.properties
wrapper.java.additional.3=-Djava.library.path=C:\Genesis\jni-lib
wrapper.java.additional.4=-Dedu.virginia.vcgr.genii.client.configuration.base-dir=C:\Genesis
wrapper.app.parameter.1=org.morgan.util.launcher.Launcher
wrapper.app.parameter.2=C:\Genesis\jar-desc.xml
wrapper.app.parameter.3=edu.virginia.vcgr.genii.container.Container
wrapper.logfile=C:\Genesis\jboss-3.0.4\logs\wrapper.log
wrapper.console.title=Genesis II Container
wrapper.ntservice.name=GenesisII
wrapper.ntservice.displayname=Genesis II
wrapper.ntservice.description=Genesis II Container
wrapper.ntservice.process_priority=LOW

The process_priority setting is important to set on shared computers. If you want the container to be secondary to any other processes, then set it to LOW. For a full description, see its property page.

Here is the full list of configurable properties for wrapper.conf.

Usage

Once configured, you may now install Genesis II as a service. Per the Java Service Wrapper guide, it is a very good idea to test your container before actually installing a service.

Testing

Run JBoss.bat from the bin directory of your JBoss installation. If you find no error messages, you may shut it down and proceed to installing as a service.
If you do encounter an error, here are a few possible places where I have had problems:

    Installation of JBoss did not work properly. 
FIX: Run run.bat from the bin directory of your JBoss installation. It might be good to run it from the command line to catch all output.
If it starts successfully, then the problem is further down this list.
Installation of Java did not set environment variables.
FIX: It is important to note that the JAVA_HOME environment variable must be set for "wrapper.java.classpath.2=\lib\tools.jar" to be acceptable.
Also, the correct version of Java must refer to the Java command. You may set this explicitly by changing the wrapper.java.command property.
For any errors that appear to occur that specifically mention anything with Genesis II, you should run runContainer.bat from within C:\Genesis
to make sure that your Genesis II installation is setup properly.

You may also check the logs directory of your JBoss installation, which may contain helpful information.

Installing the Service

Run InstallApp-NT.bat from the bin directory of your JBoss installation. You must have administrative privileges on that machine to install a service.
You will receive an error if you do not have access. You may check whether or not the installation was successful by going to Start->run and typing "services.msc".
If everything was configured properly, then you should see a new service named Genesis II.
The startup type by default is automatic, which may be changed by altering the wrapper.ntservice.starttype property. To start the service, either reboot the machine, or right click on the service and select start.

Uninstalling

Run UninstallApp-NT.bat from the bin directory of your JBoss installation. To check whether or not the removal succeeded, run "services.msc" and make sure that there is no longer a Genesis II service listed.

Linux Notes

For use with linux installations, use the jboss program in the bin directory of your JBoss installation. You may test it by running it from the console: "./jboss console" or you may set it to run as a daemon: "./jboss start". Type "./jboss" for a list of all acceptable usages.


Integration by Coding

Instructions for this integration technique are located here. It is preferable to use this method, if possible, because it does not require a middleware application, such as JBoss.


GeniiNet Installer Package

Install zip

You may download a copy of the installer here. It is meant for use with a usb key. Running the installer bat will install a copy of Genesis II on the machine.
It will keep track of that computer's local IP address so that you can attach it to GeniiNet in the next step.

Install script

I wrote a small perl script that will take the list of ip's generated by the installer and will turn it into a Genesis II script. The output script will attach each host to GeniiNet and will set security on it.