0

I have a JBOSS AS 7.1.1.final which runs as a service on windows 7. But, the problem is that because of this line(from service.bat), it ignores my JAVA_OPTS from standalone.bat.

set JAVA_OPTS=-Xrs

So, because I had some memory problems I had to comment that line in order for my service to see my standalone.bat. And this works perfectly on windows 7.

But, when I use this on windows server 2008, it doesn't work anymore. The service doesn't start at all if that line is commented and this attracts to itself memory problems.

What should I do ?

Later edit:

my service.bat:

   @echo off



   @if not "%ECHO%" == "" echo %ECHO%
   @if "%OS%" == "Windows_NT" setlocal
   set DIRNAME=%CD%

   set SVCNAME=SERVER
   set SVCDISP=SERVER
   set SVCDESC=Jboss7.1.1 GA/Platform: Windows x86
   set NOPAUSE=Y


   REM 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


   :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 -iwdc %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%" > standalone.log
   echo jbosssvc.exe -p passed
   call standalone.bat < .r.lock >> standalone.log 2>&1
   echo standalone.bat passed
   jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> standalone.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 jboss-cli.bat --connect command=:shutdown >> 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 jboss-cli.bat --connect command=:shutdown >> 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%" >> standalone.log
call standalone.bat --server-config=standalone.xml < .r.lock >> standalone.log 2>&1
jbosssvc.exe -p 1 "Shutdown %SVCDISP% service" >> standalone.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

and my standalone.conf.bat:

rem Uncomment the following line to disable manipulation of JAVA_OPTS (JVM parameters)
rem set PRESERVE_JAVA_OPTS=true

if not "x%JAVA_OPTS%" == "x" (
  echo "JAVA_OPTS already set in environment; overriding default settings with values: %JAVA_OPTS%"
  goto JAVA_OPTS_SET
)


set "JAVA_OPTS=-Xms1024M -Xmx2048M -XX:MaxPermSize=256M -Xss2m -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"

rem # Reduce the RMI GCs to once per hour for Sun JVMs.
set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true"

rem # Warn when resolving remote XML DTDs or schemas.
set "JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true"

rem # Make Byteman classes visible in all module loaders
rem # This is necessary to inject Byteman rules into AS7 deployments
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman"

rem # Set the default configuration file to use if -c or --server-config are not used
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.server.default.config=standalone.xml"

:JAVA_OPTS_SET
  • There's probably a way to reuse the existing options and add `-Xrs` (for example, invoking a child `cmd` with the combined option created in its environment), please edit the question and add the code of related files (`service.bat` and `standalone.bat`). – wOxxOm Sep 03 '15 at 11:19
  • I added the relevant code. – George-Blackstar7 Sep 04 '15 at 05:47

0 Answers0