wiki:WindowsService

Address Book Server as Windows Startup Service

The following process will take you through the installation of Address Book Server on Windows as well as running it as a Windows Service on Startup.

1.) Install JDK 1.6 from Sun (Java SE Development Kit (JDK) 6 Update 11)  JDK from Sun

2.) Configure the JAVA_HOME environment variable. To do this right-click on My Computer, then click on :

  • Advanced Properties
  • Environment Variables
  • New... under the System Variable section

3.) Install Bonjour for Windows available  here.

4.) Extract the Address Book Server archive (ABS_17_JAN_2009_GENERIC_SERVER.zip) into the root of C:\

5.) Open up a CMD and navigate to the bin directory

6.) Then start the server in debug mode via the catalina.bat run command

c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18\bin>catalina.bat run 
Address Book Server Customisation 
JAVA_OPTS :  -Dfile.encoding=UTF-8 -DH2_TCP_PORT=48081 -DH2_WEB_PORT=48082 
-Dorg.apache.el.parser.COERCE_TO_ZERO=false -Dcom.addressbookserver.ENABLE_BONJOUR=tr 
ue -Dcom.addressbookserver.ENABLE_H2=true -Dcom.sun.management.jmxremote -Djava.library.path=C:\Windows\System32 
Using CATALINA_BASE:   c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18 
Using CATALINA_HOME:   c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18 
Using CATALINA_TMPDIR: c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18\temp 
Using JRE_HOME:        C:\Program Files\Java\jdk1.6.0_10 
01-Dec-2008 22:18:52 org.apache.catalina.core.AprLifecycleListener init

7.) You can stop the command via CTRL+C which should return you to a prompt

8.) To install the service run : service.bat install to create a new startup service using default parameters

c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18\bin>service.bat install

9.) Modify the default configuration using : tomcat6w.exe ESTomcat6

c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18\bin>tomcat6w.exe //ES//Tomcat6
  • On the General Tab set the Startup Type to : Automatic
  • On the Logging Tab set the log directory to
    c:\addressBookServerEnterpriseEdition\apache-tomcat-6.0.18\logs
    
  • On the Java Tab add the following parameters on the Java Options sections
    -Dfile.encoding=UTF-8
    -DH2_TCP_PORT=48081
    -DH2_WEB_PORT=48082
    -Dorg.apache.el.parser.COERCE_TO_ZERO=false
    -Dcom.addressbookserver.ENABLE_BONJOUR=true
    -Dcom.addressbookserver.ENABLE_H2=true
    -Dcom.addressbookserver.H2_DATABASE=C:\\addressBookServerEnterpriseEdition\\apache-tomcat-6.0.18\\db
    -Dcom.addressbookserver.H2_BACKUPS=C:\\addressBookServerEnterpriseEdition\\apache-tomcat-6.0.18\\backups
    -Dcom.sun.management.jmxremote
    -Djava.library.path=C:\Windows\System32
    

10.) Adjustments for Windows to server.xml. Change the url attribute in two placed in the conf/server.xml file as shown below. The path specified in the previous step must match the folder used in the database connection url. The default path should be set to : jdbc:h2:file:C:/addressBookServerEnterpriseEdition/apache-tomcat-6.0.18/db/AddressBookDB

   <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="webapps"
            unpackWARs="false" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
        <Context path="" docBase="AddressBookServer.war">
          <Resource name="jdbc/AddressBookDB" auth="Container" type="javax.sql.DataSource"
             maxActive="25" maxIdle="5" maxWait="-1"
             username="sa" password="" driverClassName="org.h2.Driver"
	     url="jdbc:h2:file:C:/addressBookServerEnterpriseEdition/apache-tomcat-6.0.18/db/AddressBookDB"/>
          <Realm className="org.apache.catalina.realm.JDBCRealm"
            driverName="org.h2.Driver"
            connectionURL="jdbc:h2:file:C:/addressBookServerEnterpriseEdition/apache-tomcat-6.0.18/db/AddressBookDB"
            connectionName="sa" connectionPassword=""
            userTable="WEBUSERS" userNameCol="USERID" userCredCol="PASSWORD"
            userRoleTable="WEBROLES" roleNameCol="ACCESSROLE"/>
        </Context>
      </Host>
    </Engine>

These steps are also covered, including screen shots in the ABS_Windows_Service.pdf file in the Documentation/Useful? folder of the DMG.

Windows 2008 Considerations

If you want to use Windows 2008 please have a look at the following links for additional information regarding running Tomcat as a Windows Service.

 Windows Service on 2008  Java Forum Thread  Getting around UAT