-
15. Re: How to run JBoss AS as Windows Service
yhovart Jun 5, 2009 3:34 AM (in response to jochen.reinhardt)First of all, thx.
JAVA_HOME is set :JAVA_HOME=C:\Program Files\Java\jdk1.6.0_12.
Here are the Java options included by the run.conf.bat:
Dev instance:rem # rem # dev rem # set "JAVA_OPTS=-Xms128M -Xmx512M -XX:MaxPermSize=256M" set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000" set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true" set "JAVA_OPTS=%JAVA_OPTS% -XX:NewRatio=3"
Integration Instance:rem # rem # integration rem # set "JAVA_OPTS=-Xms768M -Xmx768M -XX:MaxPermSize=256M" set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000" set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true" set "JAVA_OPTS=%JAVA_OPTS% -XX:NewRatio=3 -XX:+UseParallelGC"
I have also modifiy the service.bat to add -b option to the run.bat.
If it works, i'd rather specify the '-Djboss.bind.address' in run.conf.bat.
The whole service.bat (no other changes):
REM @echo off REM JBoss, the OpenSource webOS REM REM Distributable under LGPL license. REM See terms of license at gnu.org. REM REM ------------------------------------------------------------------------- REM JBoss Service Script for Windows REM ------------------------------------------------------------------------- @if not "%ECHO%" == "" echo %ECHO% @if "%OS%" == "Windows_NT" setlocal set DIRNAME=%CD% REM REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated REM during the build with ant filter. REM set SVCNAME=JBAS50SVC set SVCDISP=JBoss Application Server 5.1 set SVCDESC=JBoss Application Server 5.1.0 GA/Platform: Windows x86 set NOPAUSE=Y REM Suppress killing service on logoff event set JAVA_OPTS=-Xrs REM Figure out the running mode if /I "%1" == "install" goto cmdInstall if /I "%1" == "uninstall" goto cmdUninstall if /I "%1" == "start" goto cmdStart if /I "%1" == "stop" goto cmdStop if /I "%1" == "restart" goto cmdRestart if /I "%1" == "signal" goto cmdSignal echo Usage: service install^|uninstall^|start^|stop^|restart^|signal goto cmdEnd REM jbosssvc retun values REM ERR_RET_USAGE 1 REM ERR_RET_VERSION 2 REM ERR_RET_INSTALL 3 REM ERR_RET_REMOVE 4 REM ERR_RET_PARAMS 5 REM ERR_RET_MODE 6 :errExplain if errorlevel 1 echo Invalid command line parameters if errorlevel 2 echo Failed installing %SVCDISP% if errorlevel 4 echo Failed removing %SVCDISP% if errorlevel 6 echo Unknown service mode for %SVCDISP% goto cmdEnd :cmdInstall jbosssvc.exe -imwdc %SVCNAME% "%DIRNAME%" "%SVCDISP%" "%SVCDESC%" service.bat if not errorlevel 0 goto errExplain echo Service %SVCDISP% installed goto cmdEnd :cmdUninstall jbosssvc.exe -u %SVCNAME% if not errorlevel 0 goto errExplain echo Service %SVCDISP% removed goto cmdEnd :cmdStart REM Executed on service start del .r.lock 2>&1 | findstr /C:"being used" > nul if not errorlevel 1 ( echo Could not continue. Locking file already in use. goto cmdEnd ) echo Y > .r.lock jbosssvc.exe -p 1 "Starting %SVCDISP%" > run.log call run.bat -b xx.x.x.xxx < .r.lock >> run.log 2>&1 jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.log del .r.lock goto cmdEnd :cmdStop REM Executed on service stop echo Y > .s.lock jbosssvc.exe -p 1 "Shutting down %SVCDISP%" > shutdown.log call shutdown -S < .s.lock >> shutdown.log 2>&1 jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> shutdown.log del .s.lock goto cmdEnd :cmdRestart REM Executed manually from command line REM Note: We can only stop and start echo Y > .s.lock jbosssvc.exe -p 1 "Shutting down %SVCDISP%" >> shutdown.log call shutdown -S < .s.lock >> shutdown.log 2>&1 del .s.lock :waitRun REM Delete lock file del .r.lock > nul 2>&1 REM Wait one second if lock file exist jbosssvc.exe -s 1 if exist ".r.lock" goto waitRun echo Y > .r.lock jbosssvc.exe -p 1 "Restarting %SVCDISP%" >> run.log call run.bat -b xx.x.x.xxx < .r.lock >> run.log 2>&1 jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> run.log del .r.lock goto cmdEnd :cmdSignal REM Send signal to the service. REM Requires jbosssch.dll to be loaded in JVM @if not ""%2"" == """" goto execSignal echo Missing signal parameter. echo Usage: service signal [0...9] goto cmdEnd :execSignal jbosssvc.exe -k%2 %SVCNAME% goto cmdEnd :cmdEnd
-
16. Re: How to run JBoss AS as Windows Service
yhovart Jun 5, 2009 4:32 AM (in response to jochen.reinhardt)After rebooting, the server started with "service start" but i got a permgenspace error.
I copied the JAVA_OPTS from my run.conf.bat into the service.bat and then it works.
Maybe the run.conf.bat is not taken into account when starting as a service, i should check that.
I also notice that declaring the -Djboss.bind.adress in run.conf.bat isn't enough so i leave the hardcoded -b option in service.bat.
Thx for your help. -
17. Re: How to run JBoss AS as Windows Service
peterj Jun 5, 2009 1:00 PM (in response to jochen.reinhardt)JAVA_HOME is set :
Where is it set, in the user or the system properties? Based on the console log you posted earlier I suspect it is set in user properties - it should be set in system properties.Maybe the run.conf.bat is not taken into account when starting as a service
Again, looking at the console log I see this:Calling C:\_dev\jboss-5.1.0.GA\bin\run.conf.bat
so I am not sure why the options are not being picked up in run.conf.bat.I also notice that declaring the -Djboss.bind.adress in run.conf.bat isn't enough
That is because the -b option sets more than the jboss.bind.address; you can look at the source code to see the other things being set from -b. -
18. How to run JBoss AS as Windows Service
gburdett Mar 8, 2011 5:22 PM (in response to peterj)I noticed the same issue with JBoss 5 - it ran fine from the command line, but froze up when I started it as a service. The JAVA_OPTS were not being picked up from run.conf.bat. Here is why:
In service.bat, the JAVA_OPTS are set initially at the top:
set JAVA_OPTS=-Xrs
Then in run.conf.bat there is this construct:
if not "x%JAVA_OPTS%" == "x" goto JAVA_OPTS_SET
...
... Commands that set the JAVA_OPTS here ...
At the end of the file, we see:
:JAVA_OPTS_SET
In other words, "if the JAVA_OPTS are non-empty, skip over the setting of them and go to the end of the script".
The problem was solved by changing the original line I referred to in service.bat to add my JAVA_OPTS, like this.
set JAVA_OPTS=-Xrs -Xmx2048m -Xms1024m -Xmn512m -XX:MaxPermSize=256M
That worked, and JBoss 5.1 runs fine as a service for me now.
-
19. How to run JBoss AS as Windows Service
jiriksykora Apr 5, 2011 4:22 AM (in response to jochen.reinhardt)From version jboss-5.0.1.GA works fine 'service.bat install' in windows, but I need install older version jboss-4.2.3.GA as service; bin folder does not contain 'service.bat install' .How is better way to install this version on windows server 2003 as service
-
20. How to run JBoss AS as Windows Service
peterj Apr 5, 2011 10:11 AM (in response to jiriksykora)You can download JBoss Native or download JBoss AS 5.1.0.GA and copy the bin/service.bat and bin/jbosssvc.exe files to your 4.2.3 bin directory.