5 Replies Latest reply on May 26, 2014 6:13 AM by vandamo

    CLI command to identify an application deployed or not in Jboss 7

    divya_ah

      Hi,

       

      My application is currently deployed in domain mode on jboss as7. My application is deployed using CLI command. Using CLI, before i deploy my application i want to check if my application is already deployed(sort of validation check). i need to do this programatically, so Is there any CLI command for achieving this.

       

      Thanks,

      Divya

        • 1. Re: CLI command to identify an application deployed or not in Jboss 7
          wdfink

          If you know which server-group and which name here an example:

           

          [domain@localhost:9999 /] /server-group=quickstart-ejb-multi-appOne-server/deployment=jboss-ejb-multi-server-app-one.ear:read-resource

          {

              "outcome" => "success",

              "result" => {

                  "enabled" => true,

                  "name" => "jboss-ejb-multi-server-app-one.ear",

                  "runtime-name" => "jboss-as-ejb-multi-server-app-one.ear"

              }

          }

          • 2. Re: CLI command to identify an application deployed or not in Jboss 7
            divya_ah

            - server-group information is not available. Using CLI , first a server-group will be created and then the application will be deployed. Before this step, i need to check if my application is deployed(this is like a validation step before creating server-group and deploying the app on this server-group)

             

            - Also, can you tell me is there any CLI command to get information if my jboss as7 is running in domain mode. In standalone mode i could achieve this using 'server-state' option like below:

            jboss-cli.bat -c --commands="read-attribute server-state"

            In domain mode above command output throws "JBAS014792: Unknown attribute server-state" error. Is there any other way to do this using CLI.

            • 3. Re: CLI command to identify an application deployed or not in Jboss 7
              wdfink

              Not sure whether there are commands to check which mode is active.

              But maybe a newer AS version might help, which one you are using?.

              From AS7.2 (IIRC) you will have "IF" control statements to have a bit more posibillities with CLI scripting

              • 4. Re: CLI command to identify an application deployed or not in Jboss 7
                divya_ah

                I am using Jboss AS 7.2.0.Final-redhat-8 "Janus".

                 

                Can you tell me the CLI cmd for this if its available in this version.

                • 5. Re: CLI command to identify an application deployed or not in Jboss 7
                  vandamo

                  Hi,

                  I see the question dates a bit, but if you still need the info:

                   

                  To identify whether you're in standalone or domain mode:

                        /:read-attribute(name=launch-type)

                       Result: DOMAIN or STANDALONE

                   

                  For your application to be deployed, you'd need to check at 2 levels:

                       1.  Is your application uploaded?

                            Multiple ways to check that, for example:

                                 /deployment=yourapplication.war:read-resource()

                            So if not present, you should get a "failed" outcome similar to this:

                            {

                                "outcome" => "failed",

                                "failure-description" => "JBAS014807: Management resource '[(\"deployment\" => \"yourapplication.war\")]' not found",

                                "rolled-back" => true

                            }

                   

                       2.  Is your application deployed to a server group?

                            (We assume then here that you are in DOMAIN mode)

                            To the best of my knowledge, there is no way in CLI to see that directly, apart from:

                            A. checking every existing server-group:

                                 /:read-children-names(child-type=server-group)

                                 {

                                      "outcome" => "success",

                                      "result" => [

                                           "ServerGroup1",

                                           "ServerGroup2",

                                           "ServerGroup3"

                                      ]

                                 }

                                 if you are indeed in DOMAIN mode, the outcome should be success even if you don't have a server-group defined.

                                 in that case the result would be an empty array.

                            B. iterating through the list to check if the application has been assigned to any of them:

                                      /server-group=ServerGroup1/deployment=yourapplication.war:read-resource()

                                 If it is assigned to the server group, result will be:

                                      {

                                           "outcome" => "success",

                                           "result" => {

                                                "enabled" => "true",

                                                "name" => "yourapplication.war",

                                                "runtime-name" => "yourapplicationRUNTIMENAME.war"

                                           }

                                      }

                                 If not, result will be:

                                      {

                                           "outcome" => "failed",

                                           "failure-description" => "JBAS014807: Management resource '[

                                                (\"server-group\" => \"ServerGroup1\"),

                                                (\"deployment\" => \"yourapplication.war\")

                                           ]' not found",

                                           "rolled-back" => true

                                      }


                            Note that it could be assigned to the server group, without being enabled.