Running JBoss AS 7 as a Windows service



This tutorial shows you how to run a JBoss AS 7 server as a Windows Service.

First of all, grab the appropriate native connectors from http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10 (x86 for 32bit host, x64 for 64bit). If you are not sure, use the 32bit version since they will work on 64bit systems also but the reverse is not true. Unzip the archive in the JBoss main folder. Then make some modifications to the service.bat file

  1. Rename the SVCNAME, SVCDISP and SVCDESC to something more meaningful. This is optional but if you plan to install multiple servers (e.g. test and production, you want different names.
  2. Modify the JAVA_OPTS to increase memory, service.bat doesn’t read any other conf.bat file so it will use default memory settings and will die of memory loss for a mid-sized deployment. Keep the -Xrs setting as I’ve seen cases where a RDP logout has caused JBoss to shut down. You might also want to add a JAVA_HOME if it’s not set as a system wide environment variable
  3. Change all run.bat calls to standalone.bat calls as they are called nowadays
  4. Comment out all “call shutdown” calls and replace then with call jboss-cli.bat –connect command=:shutdown >> shutdown.log 2>&1. This is especially important because the shutdown.bat that was around before is no longer there and it will probably run shutdown.exe from system32 instead, causing a server shutdown. If you run multiple servers you must config the CLI script to connect to the correct management ports set in standalone.xml by adding a –controller=host:mport to the bat call.
  5. Install the service with “service install”. You might also want to change the service starting mode to “automatic” and change the “run as” to a normal user. Note that on later Windows-versions, you must run the executing cmd in administrator mode.

Remember that this only takes care of the startup – you will still have to e.g. change the binding interface with -Djboss.bind.address=0.0.0.0 or -b 0.0.0.0 a <any-address/> (see the documentation for details) if you want the server to be accessible from an non-local host.