2 Replies Latest reply on Nov 26, 2014 10:56 PM by sbass

    Unable to shutdown JBoss AS 7.1.1 on Windows using the CLI

    sbass

      Hi,

       

      I've got a standalone server listening on non-default ports (port-offset=300).  I've tried using jboss-cli.bat to shutdown the server, but I can only get it to work in interactive mode.  I've got a similar jboss-cli.ps1 script (from the WildFly GitHub), but it too has the same errors.

       

      To me it looks like the arguments aren't getting parsed correctly, but that's just my guess.

       

      Here is output from the jboss-cli.bat session.  Any ideas how to get this to work?

       

      D:\jboss-as-7.1.1.Final\bin>jboss-cli.bat
      You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
      [disconnected /] connect localhost:10299 <<< THIS WORKS
      [standalone@localhost:10299 /] :shutdown <<< THIS WORKS
      {"outcome" => "success"}
      [standalone@localhost:10299 /] quit
      
      
      Press any key to continue . . .
      
      
      D:\jboss-as-7.1.1.Final\bin>jboss-cli.bat --connect localhost:10299  <<< THIS FAILS, SAME SETTING AS THE INTERACTIVE SESSION
      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:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              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
      Press any key to continue . . .
      
      
      D:\jboss-as-7.1.1.Final\bin>jboss-cli.bat --connect :10299
      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:57)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:606)
              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
      Press any key to continue . . .
      
      
      D:\jboss-as-7.1.1.Final\bin>jboss-cli.bat --connect localhost:10299 --command=:shutdown <<< THIS IS REJECTED WITHOUT EVEN ATTEMPTING TO CONNECT
      Duplicate argument '--command'/'--commands'.
      Press any key to continue . . .
      
      
      D:\jboss-as-7.1.1.Final\bin>
      

       

      For the last example, I also tried:

       

      -command=:shutdown

      command=:shutdown

      :shutdown

       

      All with the same error.and=:shutdown

        • 1. Re: Unable to shutdown JBoss AS 7.1.1 on Windows using the CLI
          jaysensharma

          Can you try using the "controller" argument while connecting to JBoss something as following :

           

          jboss-cli.bat  -c  controller=localhost:10299
          
          

           

          And

           

          jboss-cli.bat  -c  controller=localhost:10299  command=":shutdown"
          
          
          • 2. Re: Re: Unable to shutdown JBoss AS 7.1.1 on Windows using the CLI
            sbass

            Thanks for the quick reply, much appreciated.

             

            All these permutations below worked - the "secret" is specifying the connect (-c) parameter along with the other parameters:

             

            .\jboss-cli.ps1 --connect --controller=localhost:10299 --command=:shutdown
            .\jboss-cli.ps1 -c --controller=localhost:10299 --command=:shutdown
            .\jboss-cli.ps1 -c controller=localhost:10299 command=:shutdown
            .\jboss-cli.ps1 -c controller=:10299 command=:shutdown
            .\jboss-cli.ps1 -c controller=:10299 :shutdown
            
            

             

            One last question:  if I'm running a domain controller, can I also shutdown/restart the domain controller itself?  I've hit ":<tab>", here are the results, I don't see a choice to shutdown the domain controller:

             

            PS D:\jboss-as-7.1.1.Final\bin> .\jboss-cli.ps1 -c controller=localhost:9999
            14:49:26,132 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
            14:49:26,633 INFO  [org.xnio] XNIO Version 3.0.3.GA
            14:49:26,648 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
            14:49:26,658 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.3.GA
            [domain@localhost:9999 /] :
            
            
            add-namespace                  add-schema-location            delete-snapshot                full-replace-deployment        list-snapshots                 read-attribute
            read-children-names            read-children-resources        read-children-types            read-config-as-xml             read-operation-description     read-operation-names
            read-resource                  read-resource-description      remove-namespace               remove-schema-location         resolve-expression-on-domain   restart-servers
            start-servers                  stop-servers                   take-snapshot                  undefine-attribute             upload-deployment-bytes        upload-deployment-stream
            upload-deployment-url          validate-address               validate-operation             whoami                         write-attribute
            [domain@localhost:9999 /] :
            
            

             

            Whether I go with multiple standalone instances on the one server, or I use a domain controller with multiple servers, I need to configure this as a Windows service, so need the ability to shutdown/restart the service via the CLI.