3 Replies Latest reply on Dec 18, 2014 9:20 AM by Jay SenSharma

    How to locate Domain Controller from a WildFly instance.

    blue moon Newbie

      So once the apps are deployed on servers and there are multiple server groups, each of which running a different set of apps. What is a good way to


      1. locate Domain Controller from a server.

      2. retrive back a list of the running apps + their build numbers (the list includes the apps that are deployed on the servers belonging to the same server group)


      OR if this information is already stored somewhere on the server itself, where would that be?



        • 1. Re: How to locate Domain Controller from a WildFly instance.
          ksreen Newbie

          For (1)  In order to locate a server instance in CLI or Web Management GUI, you would have to traverse through it's Domain/Host Controller. The Runtime Tab -> Server Instances page displays the  Host Controller name at the top of the page. You can also use the  Server Dropdown at the top left hand corner to check the list of HC and server associated. On CLI the following command might be useful /host=master/server-config=*:read-resource For (2), have you tried the CLI and Web Management GUI?  The Server Group Deployments should give the information of running Apps. On CLI you can try the following command /server-group=*/deployment=*/:read-resource(recursive=false,proxies=true,include-runtime=true,include-defaults=true)

          1 of 1 people found this helpful
          • 2. Re: How to locate Domain Controller from a WildFly instance.
            blue moon Newbie

            Thank you ksreen.


            I'm looking for a way to do this programmatically, and from one of the apps deployed on a wildfly instance. I found out the DC can be looked up from the JVM Environment Properties. I believe both CLI and GUI use interfaces that accept queries from outside the deployment environment and login credentials must be supplied, but since we're already inside this environment I'm looking for a shortcut way to do this without passing in any login information.

            • 3. Re: Re: How to locate Domain Controller from a WildFly instance.
              Jay SenSharma Master

              You mentioned:

              I'm looking for a way to do this programmatically,


              Yes, you can run the same commands using java program as well.


              import java.io.IOException;
              // CLI API
              import org.jboss.as.cli.CommandContext;
              import org.jboss.as.cli.CommandContextFactory;
              import org.jboss.as.cli.CommandLineException;
              import org.jboss.as.cli.CommandFormatException;
              import org.jboss.as.controller.client.ModelControllerClient;
              // DMR API
              import org.jboss.dmr.ModelNode;
              public class Main
                 public static void main(String[] args) throws CommandLineException, IOException
                    String host = args[0];;
                    int port = Integer.parseInt(args[1]);
                    String appPath=args[2];
                    Main main=new Main();
                    CommandContext ctx = CommandContextFactory.getInstance().newCommandContext("admin","admin@123".toCharArray());
                    ctx.connectController(host, port);
                    ModelNode deployRequest = null;
                    try {
                              String request="/server-group=*/deployment=*/:read-resource(recursive=false,proxies=true,include-runtime=true,include-defaults=true)";
                              //String request="/host=master/server-config=*:read-resource";
                              deployRequest = ctx.buildRequest(request);
                    } catch (CommandFormatException e) {
                 public void runCommands(CommandContext ctx,ModelNode modelNode) { 
                       System.out.println("Running command ---- ");
                       ModelControllerClient client = ctx.getModelControllerClient();
                       if(client != null) {
                          try {
                                ModelNode response = client.execute(modelNode);
                                System.out.println("\n\t response = > "+response);
                          } catch (IOException e) {
                       } else {
                            System.out.println("the client (ModelControllerClient) is not available. Connection error");



              NOTE: Name sure to add the "$WILDFLY_HOME/bin/client" JAR in the client class-path while compiling and running the above code.

              Above program shows that your client can connect to WildFly remotely.   But it is also possible to connect to WildFly from within the same container. (no need to pass URL and credentials)