HomeDocumentation > Administration > Configuring Geronimo as a Windows Service
{scrollbar}

top

This article will show you how to configure Apache Geronimo v2.0 to run as a MS Windows service. A Java Service Wrapper will be required as an additional software to achieve this configuration. Using a service wrapper gives you some additional "control" on the service you are configuring such as the ability to ping the service and take action if the service is down.

Software prerequisites

To set up Apache Geronimo v2.0 to run as a MS Windows service you will certainly need a Java Service Wrapper. For this example we used Java Service Wrapper 3.2.3 available for download at the following URL:

http://sourceforge.net/projects/wrapper/

For this example we are also using Apache Geronimo v2.0 running on Windows XP. You can download Apache Geronimo binaries from the following URL:

http://geronimo.apache.org/downloads.html

Installing Apache Geronimo

The installation of Geronimo from the binaries is very simple. Just extract the zip file to a directory of your convenience, throughout the rest of the article this directory will be referred to as <geronimo_home>.

Installing the Java Service Wrapper

Installing the wrapper is as simple as installing Apache Geronimo. Once you downloaded the right version for your environment you can extract the zip file to a directory of your convenience, throughout the rest of the article this directory will be referred to as <jsw_home>.

For this particular example we will try to locate all the wrapper related files within the Geronimo directory structure, so we will have to copy some files over.

Once you installed the wrapper copy these as indicated in the following table.

Source

Destination

<jsw_home>/bin/wrapper.exe

<geronimo_home>/bin/wrapper.exe

<jsw_home>/lib/wrapper.jar

<geronimo_home>/lib/wrapper.jar

<jsw_home>/lib/wrapper.dll

<geronimo_home>/lib/wrapper.dll

In addition, the following files will also be created as part of this configuration process.

Configuring the wrapper

The Java Service Wrapper comes with a sample configuration file wrapper.conf pre-configured to run a test script also provided, this file located in the <jsw_home>\conf directory. In this section we provide a Geronimo specific wrapper.conf file for your convenience.

As we are trying to keep all the wrapper files within Geronimo's directory structure, create the configuration file as illustrated in the following example and place it in the <geronimo_home>/var/conf/wrapper.conf directory.

solidwrapper.conf # Location of java.exe (in Windows) wrapper.java.command=<java_home>/bin/java # These additional parameters are required to start the server since we are not setting any environment variables prior to running the wrapper. wrapper.java.additional.1=-javaagent:"<geronimo_home>/bin/jpa.jar" wrapper.java.additional.2=-Djava.ext.dirs="<geronimo_home>/lib/ext;<java_home>/jre/lib/ext" wrapper.java.additional.3=-Djava.endorsed.dirs="<geronimo_home>/lib/endorsed;<java_home>/jre/lib/endorsed" wrapper.java.additional.4=-Dorg.apache.geronimo.base.dir="<geronimo_home>" wrapper.java.additional.5=-Djava.io.tmpdir="<geronimo_home>/var/temp" # Good old classpath, make sure to include /bin/server.jar and /bin/shutdown.jar wrapper.java.classpath.1=../lib/wrapper.jar wrapper.java.classpath.2=../bin/server.jar wrapper.java.classpath.3=../bin/shutdown.jar wrapper.java.classpath.4=../lib/geronimo-cli-2.0-SNAPSHOT.jar wrapper.java.classpath.5=../lib/geronimo-kernel-2.0-SNAPSHOT.jar wrapper.java.classpath.6=../lib/geronimo-transformer-2.0-SNAPSHOT.jar wrapper.java.classpath.7=../lib/commons-cli-1.0.jar wrapper.java.classpath.8=../lib/commons-logging-1.0.4.jar wrapper.java.classpath.9=../lib/cglib-nodep-2.1_3.jar wrapper.java.classpath.10=../lib/log4j-1.2.14.jar wrapper.java.classpath.11=../lib/xpp3-1.1.3.3.jar wrapper.java.classpath.12=../lib/xstream-1.1.3.jar # Location of the wrapper.dll (in Windows) wrapper.java.library.path.1=../lib # Main class the wrapper will use. wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp # Geronimo start class and parameters. wrapper.app.parameter.1=org.apache.geronimo.cli.daemon.DaemonCLI # Log settings. wrapper.console.format=PM wrapper.console.loglevel=INFO wrapper.logfile=../var/log/wrapper.log wrapper.logfile.format=LPTM wrapper.logfile.loglevel=INFO wrapper.logfile.maxsize=0 wrapper.logfile.maxfiles=0 wrapper.syslog.loglevel=INFO # Windows service name and description. wrapper.console.title=Apache Geronimo v2.0 Server wrapper.ntservice.name=Geronimo wrapper.ntservice.displayname=Apache Geronimo v2.0 Server wrapper.ntservice.description=Apache Geronimo v2.0 Server wrapper.ntservice.dependency.1= wrapper.ntservice.starttype=AUTO_START wrapper.ntservice.interactive=false

This service wrapper allows three different methods of integration depending on, among other things, whether you use the same class or not to start and stop the server.

For Geronimo we will use the simplest method of integration as the server can shutdown cleanly when System.exit() is called. For this integration the wrapper's mainclass is set to WrapperSimpleApp and the org.apache.geronimo.cli.daemon.DaemonCLI class is specified as the main class to start the server. Right now, no extra parameters are passed to start the server but they can be specified by adding additional wrapper.app.parameter values. The wrapper will stop the server by calling System.exit().

As we mentioned before, for this example we are trying to locate all the wrapper related files within the Geronimo directory structure. As you can see in the wrapper.conf shown above, most of the directory references are relative to Geronimo's installation directory. You will only have to replace <geronimo_home> and <java_home> with the appropriate settings for your environment.

Next we will create a batch file to run the service from the command line without the need of actually installing the service. This is particularly helpful when testing and debugging the configuration. Create the g_service.bat batch file in the <geronimo_home>/bin directory and copy the content of the following example.

solidg_service.bat @echo off setlocal rem Copyright (c) 1999, 2006 Tanuki Software Inc. rem rem Java Service Wrapper general startup script rem rem rem Resolve the real path of the wrapper.exe rem For non NT systems, the _REALPATH and _WRAPPER_CONF values rem can be hard-coded below and the following test removed. rem if "%OS%"=="Windows_NT" goto nt echo This script only works with NT-based versions of Windows. goto :eof :nt rem rem Find the application home. rem rem %~dp0 is location of current script under NT set _REALPATH=%~dp0 rem Decide on the wrapper binary. set _WRAPPER_BASE=wrapper set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe if exist "%_WRAPPER_EXE%" goto conf echo Unable to locate a Wrapper executable using any of the following names: echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe echo %_REALPATH%%_WRAPPER_BASE%.exe pause goto :eof rem rem Find the wrapper.conf rem :conf set _WRAPPER_CONF="%~f1" if not %_WRAPPER_CONF%=="" goto startup set _WRAPPER_CONF="%_REALPATH%..\var\config\wrapper.conf" rem rem Start the Wrapper rem :startup "%_WRAPPER_EXE%" -c %_WRAPPER_CONF% if not errorlevel 1 goto :eof pause

This file is a modified version from the one provided by the wrapper as a sample, it has been edited to specify the location of the wrapper.conf file relative to Geronimo's var/config directory.

YYou can now run Geronimo as a service from a command line, simply run the following command:

<geronimo_home>/bin/g_service.bat

You should see a screen similar to the following example, note that part has been truncated for display purposes.

#000000solid {D:\geronimo-tomcat6-jee5-2.0\bin>g_service.bat wrapper | --> Wrapper Started as Console wrapper | Launching a JVM... jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. jvm 1 | jvm 1 | Booting Geronimo Kernel (in Java 1.5.0_06)... jvm 1 | Starting Geronimo Application Server v2.0 jvm 1 | jvm 1 | [* ] 0% 0s Loading jvm 1 | [*- ] 0% 0s Loading org.apache.ge... jvm 1 | [*> ] 6% 0s Loading org.apache.ge... ... jvm 1 | [*********************************] 100% 19s Startup complete jvm 1 | Listening on Ports: jvm 1 | 1050 127.0.0.1 CORBA Naming Service jvm 1 | 1099 0.0.0.0 RMI Naming jvm 1 | 1527 0.0.0.0 Derby Connector jvm 1 | 2001 127.0.0.1 OpenEJB ORB Adapter jvm 1 | 4201 0.0.0.0 org.apache.geronimo.openejb.EjbDaemonGBean jvm 1 | 4242 0.0.0.0 Remote Login Listener jvm 1 | 6882 127.0.0.1 OpenEJB ORB Adapter jvm 1 | 8009 0.0.0.0 Tomcat Connector AJP jvm 1 | 8080 0.0.0.0 Tomcat Connector HTTP jvm 1 | 8443 0.0.0.0 Tomcat Connector HTTPS jvm 1 | 9999 0.0.0.0 JMX Remoting Connector jvm 1 | 61613 0.0.0.0 ActiveMQ Transport Connector jvm 1 | 61616 0.0.0.0 ActiveMQ Transport Connector jvm 1 | jvm 1 | Started Application Modules: jvm 1 | EAR: org.apache.geronimo.configs/webconsole-tomcat/2.0/car jvm 1 | RAR: org.apache.geronimo.configs/activemq-ra/2.0/car jvm 1 | RAR: org.apache.geronimo.configs/system-database/2.0/car jvm 1 | WAR: org.apache.geronimo.configs/dojo-tomcat/2.0/car jvm 1 | WAR: org.apache.geronimo.configs/remote-deploy-tomcat/2.0/car jvm 1 | WAR: org.apache.geronimo.configs/welcome-tomcat/2.0/car jvm 1 | jvm 1 | Web Applications: jvm 1 | http://localhost:8080/ jvm 1 | http://localhost:8080/console jvm 1 | http://localhost:8080/console-standard jvm 1 | http://localhost:8080/dojo jvm 1 | http://localhost:8080/remote-deploy jvm 1 | jvm 1 | Geronimo Application Server started

Congratulations!!! you have now Geronimo server running as a Windows service.

The next step is to actually install the service so it can be picked up at Windows start time as well as managed along with the other existing services.

Installing/Removing the service

The following two batch files are provided to install and remove Geronimo as a Windows service. Create the files in the <geronimo_home>/bin directory and copy the content as depicted in the following examples.

solidInstall_Geronimo_NT.bat @echo off setlocal rem Copyright (c) 1999, 2006 Tanuki Software Inc. rem rem Java Service Wrapper general NT service install script rem if "%OS%"=="Windows_NT" goto nt echo This script only works with NT-based versions of Windows. goto :eof :nt rem rem Find the application home. rem rem %~dp0 is location of current script under NT set _REALPATH=%~dp0 rem Decide on the wrapper binary. set _WRAPPER_BASE=wrapper set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe if exist "%_WRAPPER_EXE%" goto conf echo Unable to locate a Wrapper executable using any of the following names: echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe echo %_REALPATH%%_WRAPPER_BASE%.exe pause goto :eof rem rem Find the wrapper.conf rem :conf set _WRAPPER_CONF="%~f1" if not %_WRAPPER_CONF%=="" goto startup set _WRAPPER_CONF="%_REALPATH%..\var\config\wrapper.conf" rem rem Install the Wrapper as an NT service. rem :startup "%_WRAPPER_EXE%" -i %_WRAPPER_CONF% if not errorlevel 1 goto :eof pause

To install Apache Geronimo as a MS Windows service run the following command:

<geronimo_home>/bin/Install_Geronimo_NT.bat

You should get a confirmation screen similar to this example.

#000000solid D:\geronimo-tomcat6-jee5-2.0\bin>Install_Geronimo_NT.bat wrapper | Apache Geronimo v2.0 Server installed.

solidUninstall_Geronimo_NT.bat @echo off setlocal rem Copyright (c) 1999, 2006 Tanuki Software Inc. rem rem Java Service Wrapper general NT service uninstall script rem if "%OS%"=="Windows_NT" goto nt echo This script only works with NT-based versions of Windows. goto :eof :nt rem rem Find the application home. rem rem %~dp0 is location of current script under NT set _REALPATH=%~dp0 rem Decide on the wrapper binary. set _WRAPPER_BASE=wrapper set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe if exist "%_WRAPPER_EXE%" goto conf set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe if exist "%_WRAPPER_EXE%" goto conf echo Unable to locate a Wrapper executable using any of the following names: echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe echo %_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe echo %_REALPATH%%_WRAPPER_BASE%.exe pause goto :eof rem rem Find the wrapper.conf rem :conf set _WRAPPER_CONF="%~f1" if not %_WRAPPER_CONF%=="" goto startup set _WRAPPER_CONF="%_REALPATH%..\var\config\wrapper.conf" rem rem Uninstall the Wrapper as an NT service. rem :startup "%_WRAPPER_EXE%" -r %_WRAPPER_CONF% if not errorlevel 1 goto :eof pause

To remove the Apache Geronimo service run the following command:

<geronimo_home>/bin/Uninstall_Geronimo_NT.bat

You should get a confirmation screen similar to this example.

#000000solid D:\geronimo-tomcat6-jee5-2.0\bin>Uninstall_Geronimo_NT.bat wrapper | Apache Geronimo v2.0 Server removed.