With JBoss AS 7 lot of things have change for good and if you have noticed a lot of previous scripts have been removed due to which creating a Windows service for JBoss AS7 becomes little tricky, hence with this article we would help you create a Windows service for JBoss AS 7.

Few things to note which would help you understand this article are that as run.bat and shutdown.bat has been removed hence we would have to make some changes in the service.bat.

Steps to create Windows service in AS 7

    Download native connectors

  1. First of all you can get the latest appropriate native connectors depending on your system configurations, till now the latest JBoss native components is 2.0.10 which can be downloaded from the below given link. Once you have downloaded it unzip the archive in the JBoss bin folder.
  2. Download link: http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10

    Configuration of the Windows service

  3. Now the below changes has to be done in the service.bat file, hence it would be a good idea to keep a backup of it. To do that you can just make a copy of it and rename it as service-AS7.bat
  4. As we are going to to call service-AS7.bat we would have to make sure we have to modify this file and replace”service.bat” with “service-AS7.bat” in line number 55 as shown below
  5. jbosssvc.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service-AS7.bat
    
  6. We can change the value of SVCNAME, SVCDISP and SVCDESC, because if in future you want to run more Windows services for JBoss AS7 then these values would help you identify the services.
  7. set SVCNAME=JBossSVC-AS7
    set SVCDISP=JBossSVC-AS7
    set SVCDESC=JBoss Application Server 7.0.2 GA/Platform: Windows x86
    
  8. You can also give your java options under the JAVA_OPTS. Make sure you keep the -Xrs flag as it is been used to reduce the operating-system signals by the Java virtual machine (JVM) which helps in the case when you logout of the system the service would still be running.
  9. set JAVA_OPTS=-Xrs -Xms1024M -Xmx1024M
    
  10. As discussed earlier you would have to replace the run.bat with standalone.bat or domain.bat whichever mode you want to use to start the JBoss servers, this has to be done in the line number 75 and 104
  11. call standalone.bat  < .r.lock >> run.log 2>&1
    
  12. In JBoss AS 7 there is no script given to shutdown a server hence we would have to replace shutdown.bat in line number 84 and 94 with the below CLI command which would do the same for you
  13. call jboss-admin.bat --connect command=:shutdown >> shutdown.log 2>&1
    

    Installation the Windows service

  14. Once all these changes have been made now its time to install the JBoss AS 7 service using the service-AS7.bat script and below command
  15. D:JbossJBossAS7jboss-as-7.0.2.Finalbin>service-AS7.bat install
    Installed JBOSSSVC-AS7
    Service JBossSVC-AS7 installed
    

    Starting the Windows service

  16. After the above command is been run successfully you can go to the Windows Service console and change the respective service  Startup Type from Manual to Automatic which would make sure that whenever you start/bootup your system the JBoss AS 7 services starts up automatically.
  17. Stopping the Windows service

  18. You can use the below given command to stop the Windows service once it has been started or else you can even do the same from the Windows Service console.
  19. D:JbossJBossAS7jboss-as-7.0.2.Finalbin>service-AS7.bat stop
    

Things to know when creating multiple Windows service of JBoss AS 7

  1. Follow steps 2,3 and 4
  2. And make sure that you give different names of run.log, shutdown.log, r.lock and s.lock for all the JBoss Windows service created.

If at any step you get stuck the best way to know what went wrong you can have a look at the run.log which can be found in the “/bin” folder.

Note: In later versions of Windows OS like Vista or Windows 7 you might have to make sure that the command prompt is running in administrator mode if you want to do a service install or else you might see the below error message in your cmd prompt.

D:JbossJBossAS7jboss-as-7.0.2.Finalbin>service-AS7.bat install
Failed installing JBOSSSVC-AS7
Access is denied.

Service JBossSVC-AS7 installed
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.