12 Replies Latest reply on Apr 29, 2013 12:02 PM by dazzer001

    Jboss 7 service problem while running

    ohmygod

      I am using JBoss native service for JBoss 7 and now I have encountered a problem when JBoss 7 service is running.

       

      When the service is installed and running, executing service.bat uninstall will do the stop thing and it will be in a loop of trying to stop the service. Below is the log trace.

       

      Uninstalling DEMO
      Service Cmd    /E:ON /S /C "SET JSERVICE_PPID=9656&&SET JSERVICE_NAME=DEMO&&CALL service.bat stop"
      Stopping service DEMO
      Shutting down DEMO Service [2012-11-29 16:47:27]
      {"outcome" => "success"}
      Shutdown DEMO Service service [2012-11-29 16:47:28]
      Stopped service DEMO
      Service terminated DEMO
      Shutting down DEMO Service [2012-11-29 16:47:43]
      org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
              at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)
              at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)
              at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.modules.Module.run(Module.java:260)
              at org.jboss.modules.Main.main(Main.java:291)
      Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999
              at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)
              at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)
              at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)
              ... 8 more
      Shutdown DEMO Service service [2012-11-29 16:47:49]
      Stopped service DEMO
      Service terminated DEMO
      Shutting down DEMO Service [2012-11-29 16:48:01]
      org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
              at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)
              at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)
              at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.modules.Module.run(Module.java:260)
              at org.jboss.modules.Main.main(Main.java:291)
      Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999
              at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)
              at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)
              at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)
              ... 8 more
      Shutdown DEMO Service service [2012-11-29 16:48:07]
      Stopped service DEMO
      Service terminated DEMO
      
      

       

      What I am concerned is why it continues to try to stop the service after it stopped once.

       

      Could anybody suggest if there is a way to resolve this issue?

       

      I am attaching my service.bat.

       

       

      @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=DEMO
      set SVCDISP=DEMO Service
      set SVCDESC=DEMO Service running with JBoss Application Server 7.1.1
      set NOPAUSE=Y
      
      
      REM Suppress killing service on logoff event
      
      
      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 -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%"
      call standalone.bat < .r.lock
      jbosssvc.exe -p 1 "Shutdown %SVCDISP% service"
      del .r.lock
      goto cmdEnd
      
      
      :cmdStop
      REM Executed on service stop
      echo Y > .s.lock
      jbosssvc.exe -p 1 "Shutting down %SVCDISP%"
      call jboss-cli.bat --connect command=:shutdown
      jbosssvc.exe -p 1 "Shutdown %SVCDISP% service"
      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%"
      call jboss-cli.bat --connect command=:shutdown
      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%"
      call standalone.bat < .r.lock
      jbosssvc.exe -p 1 "Shutdown %SVCDISP% service"
      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
      
      
        • 1. Re: Jboss 7 service problem while running
          ohmygod

          Anybody knows how to use service.bat uninstall to uninstall the service successfully while the service is running.

           

          Currently the problem is the command service.bat uninstall will be doing shut down service in a loop (do not end).

          • 2. Re: Jboss 7 service problem while running
            xin.zhang.song

            mike just 编写:

            Uninstalling DEMO Service Cmd    /E:ON /S /C "SET JSERVICE_PPID=9656&&SET JSERVICE_NAME=DEMO&&CALL service.bat stop" Stopping service DEMO Shutting down DEMO Service [2012-11-29 16:47:27] {"outcome" => "success"} Shutdown DEMO Service service [2012-11-29 16:47:28] Stopped service DEMO Service terminated DEMO Shutting down DEMO Service [2012-11-29 16:47:43] org.jboss.as.cli.CliInitializationException: Failed to connect to the controller         at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)         at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)         at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)         at java.lang.reflect.Method.invoke(Method.java:597)         at org.jboss.modules.Module.run(Module.java:260)         at org.jboss.modules.Main.main(Main.java:291) Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999         at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)         at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)         at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)         ... 8 more Shutdown DEMO Service service [2012-11-29 16:47:49] Stopped service DEMO Service terminated DEMO Shutting down DEMO Service [2012-11-29 16:48:01] org.jboss.as.cli.CliInitializationException: Failed to connect to the controller         at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)         at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)         at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)         at java.lang.reflect.Method.invoke(Method.java:597)         at org.jboss.modules.Module.run(Module.java:260)         at org.jboss.modules.Main.main(Main.java:291)

            //Seem like cannot connect the port 9999 Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999         at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)         at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)         at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)         ... 8 more Shutdown DEMO Service service [2012-11-29 16:48:07] Stopped service DEMO Service terminated DEMO

             

            • 3. Re: Jboss 7 service problem while running
              ohmygod

              Thanks for the reply, but the problem is why it repeats doing the shut down operation after it already shut down the service.

               

              Shutdown DEMO Service service [2012-11-29 16:47:28] Stopped service DEMO Service terminated DEMO

              • 4. Re: Jboss 7 service problem while running
                nickarls

                I see no logical way how it could end up there. Have you seen if it really goes to :cmdEnd after the first stop?

                • 5. Re: Jboss 7 service problem while running
                  ohmygod

                  How to see if it goes to :cmdEnd?

                  • 6. Re: Jboss 7 service problem while running
                    nickarls

                    just echo some output there.

                    • 7. Re: Jboss 7 service problem while running
                      ohmygod

                      The first log output is it. There is no end after nearly 10 minutes, just in a loop. Or I have not waited for enough time to see the end?..

                      • 8. Re: Jboss 7 service problem while running
                        nickarls

                        I don't see any reason why it should stop after 2 attempts if it still loops.

                         

                        Try putting an

                         

                        echo End reached

                        after :cmdEnd

                         

                        If you don't see it, the loop is inside the script...

                        when I have cases like this sometimes I add

                         

                        echo 1

                        echo 2

                        echo 3

                         

                        interleaved with the script code itself. That way I can retrace the exact path of execution

                        • 9. Re: Jboss 7 service problem while running
                          ohmygod

                          Added “echo End reached" and see the log, but it continues doing the stop operation, using service.bat uninstall. Any thoughts?

                           

                          D:\welocalize\DEMO\server\JBOSS-7.1.1.Final\DEMO\jboss\server\bin>service.bat uninstall
                          Uninstalling DEMO
                          Service Cmd    /E:ON /S /C "SET JSERVICE_PPID=7568&&SET JSERVICE_NAME=DEMO&&CALL service.bat stop"
                          Stopping service DEMO
                          Shutting down DEMO Service [2012-12-03 11:04:16]
                          {"outcome" => "success"}
                          Shutdown DEMO Service service [2012-12-03 11:04:21]
                          End reached
                          Stopped service DEMO
                          Service terminated DEMO
                          Shutting down DEMO Service [2012-12-03 11:04:35]
                          org.jboss.as.cli.CliInitializationException: Failed to connect to the controller
                                  at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:229)
                                  at org.jboss.as.cli.impl.CliLauncher.main(CliLauncher.java:195)
                                  at org.jboss.as.cli.CommandLineMain.main(CommandLineMain.java:34)
                                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                                  at java.lang.reflect.Method.invoke(Method.java:597)
                                  at org.jboss.modules.Module.run(Module.java:260)
                                  at org.jboss.modules.Main.main(Main.java:291)
                          Caused by: org.jboss.as.cli.CommandLineException: The controller is not available at localhost:9999
                                  at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:639)
                                  at org.jboss.as.cli.impl.CommandContextImpl.connectController(CommandContextImpl.java:613)
                                  at org.jboss.as.cli.impl.CliLauncher.initCommandContext(CliLauncher.java:227)
                                  ... 8 more
                          Shutdown DEMO Service service [2012-12-03 11:04:41]
                          End reached
                          Stopped service DEMO
                          Service terminated DEMO
                          Shutting down DEMO Service [2012-12-03 11:04:44]
                          
                          
                          • 10. Re: Jboss 7 service problem while running
                            nickarls

                            Umm. That's a bit too strange for me. It can't jump anywhere from the last line like that, the caller of the script must be in a loop somehow....

                            • 11. Re: Jboss 7 service problem while running
                              veitg

                              Same here. Did you ever solve the problem?

                               

                              It seems that the service.bat is called again, and again by the jbosssvc.exe.

                               

                              Update1:

                               

                              Digged deeper and it seems that jbosssvc loops in here (jboss.c):

                               

                               

                              {code}

                                  while (RunChildProcess(_cmd_exe, cmd, &prInfo)) {         WaitForSingleObject(prInfo.hProcess, INFINITE);         AddToMessageLog(FALSE, "Stopped service %s", _service_name);         CloseHandle(prInfo.hProcess);         CloseHandle(prInfo.hThread);         ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);         if (WaitForSingleObject(_service_run_event, step) == WAIT_OBJECT_0)             break;         if (step > 2000)             step = 2000;         if (difftime(time(NULL), s) > t) {             ReportServiceStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);             TerminateProcessGroup(_service_run_hproc, _service_run_pid, 1);             AddToMessageLog(FALSE, "Service terminated %s", _service_name);         }     } {code}

                               

                              I enabled the event logging via -l and I can see that "Stopped service" and "Service terminated" is printed in an endless loop. My guess is, that WAIT_OBJECT_0 will never be true.

                              Since I'm not a windows/c but java programmer, maybe a C guy can jump in and come to rescue .

                              • 12. Re: Jboss 7 service problem while running
                                dazzer001

                                I am encountering the same problem, and narrowed it down to the exact same line of code:

                                     WaitForSingleObject(_service_run_event, step) == WAIT_OBJECT_0

                                 

                                I have the problem when I try to uninstall the service when the service is still running. The above boolean expression is never true, and so the code enters a perpetual loop.

                                 

                                I would like to know why the code was designed this way. Is there a step that I missed?