How To Run JBoss J2EE Application Server as a Windows Service with FireDaemon
JBoss Application Server (JAS) is the #1 most widely used Java application server on the market. A J2EE certified platform for developing and deploying enterprise Java applications, Web applications, and Portals, JBoss Application Server provides the full range of J2EE 1.4 features as well as extended enterprise services including clustering, caching, and persistence. JAS can be run as a Windows Service using
FireDaemon. FireDaemon allows JAS to be started without the need to login and provides resiliancy in case of crash.
PanelDaemon can also be used to manage JAS and other Windows services remotely via web brower. This is how to set up JAS as a FireDaemon service:
Download and Install JAS
JAS can be downloaded
here. This HOWTO assumes you are using JBoss Application Server v4.0.3 SP1 or later. On Windows platforms, download the ZIP file and unpack to the directory of your choice. For the purposes of this HOWTO JAS is installed in: e:\jboss-4.0.3SP1. Adjust the path to suit your installation.
Download and Install Your Preferred JDK
You need a Java Development Kit (JDK) to run JAS. Sun's JDK does the job nicely. You can download it from
here. Download and install JDK 5.0 Update 6 or later. For the purposes of this HOWTO the JDK is installed in e:\java\jdk1.5.0_06. Adjust the path to suite your installation.
Install FireDaemon Pro
FireDaemon can be downloaded
from here. FireDaemon is typically installed in C:\Program Files\FireDaemon. Adjust the path to suit your installation.
Configure FireDaemon
After installing FireDaemon, double click the FireDaemon desktop icon. Create a new service by clicking on the
Create a new service definition button in the toolbar or typing Ctrl+N. The New Service Definition dialog will be displayed. Fill out the fields in the Program tab as follows (adjust paths to suite your installation):
If you want to see JBoss running in a console window, specify java.exe instead of javaw.exe in the Executable field.
The Parameters line reads:
Code:
%JAVA_OPTS% "-Djava.endorsed.dirs=%JBOSS_ENDORSED_DIRS%" -classpath "%JBOSS_RUNPATH%" org.jboss.Main
Now click on the Settings tab. Uncheck the Interact with Desktop check box unless you want to see JAS running in a console window.
Now click on the Advanced tab. Setup debug logging and stdout/stderr capture (adjust logging paths to suit) as per:
Now click on the Dependencies tab. Make the JAS service dependent on the
lanmanworkstion (Workstation) service. This ensure TCP/IP and CIFS stacks are up and running prior to the JAS service being started:
Now click on the Environment tab. You need to specify a series of Environment variables that are used to startup JAS correctly. You will need to adjust the basic paths (ie. JAVA_HOME and JBOSS_HOME) in order to suit your installation:
The environment variables to set are as follows (their order must be maintained):
Code:
JAVA_HOME: e:\java\jdk1.5.0_06
JBOSS_HOME: e:\jboss-4.0.3SP1
RUNJAR: %JBOSS_HOME%\bin\run.jar
JAVA: %JAVA_HOME%\bin\java.exe
SHUTDOWNJAR: %JBOSS_HOME%\bin\shutdown.jar
JAVAC_JAR: %JAVA_HOME%\lib\tools.jar
JAVA_OPTS: -Xrs -Xms128m -Xmx512m
JBOSS_ENDORSED_DIRS: %JBOSS_HOME%\lib\endorsed
JBOSS_RUNPATH: %JAVAC_JAR%;%RUNJAR%
JBOSS_SHUTDOWNPATH: %SHUTDOWNJAR%;%JBOSS_HOME%\client\jbossall-client.jar
Lastly click on the Pre / Post-Service tab. This is where we specify the commands to gracefully shut JAS down. Note, JBoss shutdown is asynchronous. Hence, once the shutdown is initiated FireDaemon needs to wait for the shutdown to complete prior to shutting down the service.
Click on the Append button in the Post-Service Programs section and fill out the dialog as follows (adjust paths to suit):
java.exe or javaw.exe can be used in the Executable field. The Parameters line reads:
Code:
%JAVA_OPTS% -classpath "%JBOSS_SHUTDOWNPATH%" org.jboss.Shutdown --shutdown
Then click OK. Now add the second Post-Service Program. Click on the Append button in the Post-Service Programs section and fill out the dialog as follows:
What this does is simulate a 10 second delay by pinging the loopback adapter at a rate of one packet per second. This allows JAS to shutdown before FireDaemon commences on its shutdown and cleanup tasks. Then, click OK:
Now click the Install button to start the service and JAS. Now this is where it can go all horribly wrong. If you started JAS with java.exe, Interact with Desktop set and you DIDN'T bother setting any stdout/stderr logs set expect to see a dialog box like this:
To prove that JAS is running point your browser as follows:
If you are using stdout/stderr logging then the messages normally written to the console will be in the log file. For example (editing the file with Vim):
When stopping the service, you also need to make sure JAS is being shutdown correctly. The stderr/stdout log should contain something similar to:
Issues ... other problems? Please post in the
Public Support Forums!