Home > Tech Tips > How to run JBoss Application Server as a Windows Service?

How to run JBoss Application Server as a Windows Service?

December 31st, 2012 Leave a comment Go to comments

Recently I was helping a client to install an application on JBoss 4.2.2 server and the client wanted the start and stop operation to be setup as a windows service. The answer was not straight forward and I thought of documenting all the steps I followed.

1) Download JBoss Web Native Connectors (Windows binary)
http://www.jboss.org/jbossweb/downloads


2) Unzip the Native Connector download, and copy jbosssvc.exe and service.bat to JBOSS_HOME/bin folder.


3) Edit FOUR parts of service.bat. Only 3.a is required. Other steps are optional.
3.a
Default service configuration is for JBoss 5.0 (JBAS50SVC). Change this to appropriate version of your server. In my case the server version was 4.2.2 and I have the following overrides.

 
set SVCNAME=JBAS422SVC
set SVCDISP=JBoss Application Server 4.2.2.
set SVCDESC=JBoss Application Server 4.2.2 GA/Platform: Windows x86

3.b
Override start command. In my case, I was starting a specific server with appropriate JDK and allocating enough memory before calling the run.bat program.

 
#call run.bat < .r.lock >> run.log 2>&1
#### CUSTOM START SETTING #####
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_22
set JAVA_OPTS=-Xms256m -Xmx512m -XX:MaxPermSize=1024m
call run.bat -c MyDefaultServer -b 0.0.0.0 < .r.lock >> run.log 2>&1
#########

3.c
Override shutdown command

 
#call shutdown -S < .s.lock >> shutdown.log 2>&1
#### CUSTOM SHUTDOWN SETTING #####
call shutdown -s jnp://localhost:11099 -S < .s.lock >> shutdown.log 2>&1
#########

3.b
Override restart

 
#call run.bat < .r.lock >> run.log 2>&1
#### CUSTOM START SETTING #####
set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_22
set JAVA_OPTS=-Xms256m -Xmx512m -XX:MaxPermSize=1024m
call run.bat -c MyDefaultServer -b 0.0.0.0 < .r.lock >> run.log 2>&1
#########





4) Now just go to JBOSS_HOME/bin folder and install service.bat. More instructions are included in README-service.txt which came with JBoss Web Native Connectors download.

C:\> service.bat install


5) Now if you access windows services you should see JBoss Application Server listed as a service. Default start type will be ‘Manual’. Change this to ‘Automatic’ if you want the JBoss server to be started with the machine.
JBoss_Service_Setting


Note that you can also use a wrapper service to achieve the same and I did not explore that path. Newer versions of JBoss might have this option built in and native connectors may not be required. I tested this only with Jboss versions 4.2.2 and 4.2.3.




Check the link below for more documentation
http://something-about-tech.blogspot.com/2009/01/running-jboss-as-windows-service.html

Share

Categories: Tech Tips Tags:
  1. No comments yet.
  1. No trackbacks yet.