7 Replies Latest reply on Sep 11, 2014 12:14 PM by Savas Ziplies

    Q: Adding Cli Command to Deployment Module

    Savas Ziplies Newbie

      Hi everyone

       

      Maybe this question is totally nonsense but I just tried it (not working ) and would be happy to get some feedback.

       

      So, I started of with a module maven archetype project to hook to the deployment process. So far so and everything is working installed onto Widlfly, posting some information, logs and reading the deployed WAR.

      Now, I would like to add some logic, specifically do a certain CLI call before the deployment. Everything hooks fine and I use the CommandContect and Cli Public API as described around. It works perfectly find actually, and I can read e.g. a system-property

       

      /system-property=com.insanitydesign.test:read-resource

       

      It fires, prints out the result, all good, all working. Now, I would like to add a system-property

       

      /system-property=com.insanitydesign.test:add

       

      but this has the server then hanging. If I cancel the server I get some error messages from the buffer that the CLI Command Context was not able to connect to the management API and all ends.

      As in the case of "read-resource" all is fine, I assume that there is some lock of adding something during this step, but the error message is actually far from clear to me by saying not able to connect, when absolutely the same works for reading a resource.

       

      Is this intended? Is this a known lock to add something? I am not doing much more than

       

      cmdCtx.handleSafe("/system-property=com.insanitydesign.test:read-resource"); //working

      cmdCtx.handleSafe("/system-property=com.insanitydesign.test:add"); //not-working

       

      Any help or insight would be highly appreciated.

       

       

      Thanks a lot

        • 1. Re: Q: Adding Cli Command to Deployment Module
          James Perkins Master

          You're missing the required value attribute for the add operation on system properties. The command should be something like /system-property=com.insanitydesign.test:add(value="some value")

           

          --

          James R. Perkins

          • 2. Re: Q: Adding Cli Command to Deployment Module
            Savas Ziplies Newbie

            Hi James

             

             

            Thanks for the feedback. I actually also did it with

             

              cmdCtx.handleSafe("/system-property=com.insanitydesign.test:add(value=true)"); //not-working

             

            and it was the same. I just tested and

             

              /system-property=com.insanitydesign.test:add

             

            is actually working directly through the CLI command line (sounds weird ^^). So that is unfortunately not the problem that popped up here.

             

             

            Thanks

            • 3. Re: Q: Adding Cli Command to Deployment Module
              James Perkins Master

              What is the error message you're getting? Does the property already exist when you attempt to add it?

               

              --

              James R. Perkins

              • 4. Re: Q: Adding Cli Command to Deployment Module
                Savas Ziplies Newbie

                Hi there

                 

                The error I get is that it cannot connect. I tried with an already existing property in the config and without, just to be sure.

                 

                The exact error message is:

                   org.jboss.as.cli.CommandLineException: The controller is not available at 127.0.0.1:9990

                 

                Because of that I already thought the Wildfly is not reachable but through jboss-cli directly I can access and the read commands work. I am a little unsure really where to look at based on that.

                I tried to set it to localhost, to 127.0.0.1 directly, do my systems name but always the same. From the logs I can see that it is booted there.

                 

                Code wise I tried to keep it straight by just having

                  cmdCtx.connectController();

                  cmdCtx.handle("/subsystem=logging:read-operation-names");

                  cmdCtx.handleSafe("/system-property=com.insanitydesign.test:read-resource");

                  cmdCtx.handleSafe("/system-property=com.insanitydesign.test:add");

                 

                As you can see I tried several. Read operations work, read resources work and then it fails back on

                cmdCtx.connectController();

                 

                actually. Do read operations not need a connection? Or does the connection break after an operation it cannot compute? Do I have to flag the connection accordingly?

                 

                 

                Thanks

                • 5. Re: Q: Adding Cli Command to Deployment Module
                  Savas Ziplies Newbie

                  Ok, I tried it now separated from a deployment and not inside a module and there it works. The same code triggers and fires normally.

                   

                  Now I am more confused

                  • 6. Re: Q: Adding Cli Command to Deployment Module
                    James Perkins Master

                    Are you trying to modify the system properties during the deployment process? If so that will not work. You can use tools like the wildfly-maven-plugin to configure a server before you deploy, but the server must be running.

                     

                    --

                    James R. Perkins

                    • 7. Re: Q: Adding Cli Command to Deployment Module
                      Savas Ziplies Newbie

                      Hi there

                       

                      Yes, that was my original intend and I somehow already thought that. Unfortunate but ok.

                       

                      But I have a question: If the server is already fully running and the deployment is added into a running server, should it work then or only during startup deployment is not working?

                       

                      Maven does not help me a lot there as I would like to alter multiple live servers, where I have no direct access to to fire such. Why I wanted to have a module running to do that for me. But it seems this is then something not possible.

                       

                       

                      Thanks