10 Replies Latest reply on Apr 30, 2014 11:04 AM by emuckenhuber

    failure to deploy using the http json management api?

    sachindole

      Hello,

       

      I have a domain setup with wildfly 8 and I am trying to deploy a war file using the JSON management API. I have this working for standalone, but cant seem to make it work for domain mode. Here is the two step process I follow:

       

      Step 1:

      to /management/add-content, send a post with "file" parameter set to the binary for my war file. I get a success resonse:

      {
           "outcome" : "success",
           "result" : {
                "BYTES_VALUE" : /Aa3z8JORR1HWqXu9yOKh1WLpvs="
      }}
      

       

      Step 2:

      to /management, I send a post request with this json and I get back an internal server error (code 500)

      {
           "content":[{
                "hash":{
                     "BYTES_VALUE":"8+CLT8fXmITHvIE3POn6cuQHXN0="
                     }
           }],
           "address":[{
                "deployment":"web-1.0-SNAPSHOT.war",
                "server-groups":["trelair-server-group"],
                "server":"trelair-server",
                "host":"master"
           }],
           "operation":"add",
           "enabled":"true",
      }
      

       

      The server side exception does not help much:

      2014-04-21 06:08:25,207 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final "WildFly" (Host Controller) started in 20638ms - Started 44 of 46 services (13 services are lazy, passive or on-demand)
      2014-04-21 06:08:25,348 INFO  [org.jboss.as.host.controller] (server-registration-threads - 1) JBAS010919: Registering server trelair-server
      2014-04-21 06:13:18,892 INFO  [org.jboss.as.repository] (XNIO-1 task-2) JBAS014900: Content added at location /tr/wildfly-8.0.0.Final/domain/data/content/fc/06b7cfc24e451d475aa5eef7238a87558ba6fb/content
      2014-04-21 06:14:59,959 ERROR [io.undertow.request] (XNIO-1 task-5) Blocking request failed HttpServerExchange{ POST /management}: java.lang.IllegalArgumentException
              at org.jboss.dmr.ModelValue.asProperty(ModelValue.java:96) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
              at org.jboss.dmr.ObjectModelValue.asProperty(ObjectModelValue.java:152) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
              at org.jboss.dmr.ModelNode.asProperty(ModelNode.java:372) [jboss-dmr-1.2.0.Final.jar:1.2.0.Final]
              at org.jboss.as.controller.PathAddress.pathAddress(PathAddress.java:74) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.DomainApiHandler.sendPreparedResponse(DomainApiHandler.java:286) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.DomainApiHandler.handleRequest(DomainApiHandler.java:155) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.security.SubjectDoAsHandler$1.run(SubjectDoAsHandler.java:72) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.security.SubjectDoAsHandler$1.run(SubjectDoAsHandler.java:68) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.8.0]
              at javax.security.auth.Subject.doAs(Subject.java:422) [rt.jar:1.8.0]
              at org.jboss.as.controller.AccessAuditContext.doAs(AccessAuditContext.java:94) [wildfly-controller-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.security.SubjectDoAsHandler.handleRequest(SubjectDoAsHandler.java:68) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at org.jboss.as.domain.http.server.security.SubjectDoAsHandler.handleRequest(SubjectDoAsHandler.java:63) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at io.undertow.server.handlers.BlockingHandler.handleRequest(BlockingHandler.java:50) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
              at org.jboss.as.domain.http.server.DomainApiCheckHandler.handleRequest(DomainApiCheckHandler.java:77) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]
              at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
              at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
              at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687) [undertow-core-1.0.0.Final.jar:1.0.0.Final]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0]
              at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
      

       

      What am I missing? Any suggestions either in plan json or in the jboss dmr style will help a LOT!

       

      Thank you!

       

      Sachin    

        • 1. Re: failure to deploy using the http json management api?
          sachindole

          Please be bold, even if you remember reading something somewhere or know what direction I might go, please say it here . Thank you!

          • 2. Re: failure to deploy using the http json management api?
            ctomc

            Your address format is wrong.

             

            "address":[{ 

                      "deployment":"web-1.0-SNAPSHOT.war"

                      "server-groups":["trelair-server-group"], 

                      "server":"trelair-server"

                      "host":"master" 

                 }], 

             


            • 3. Re: failure to deploy using the http json management api?
              emuckenhuber

              After adding the deployment-content in step 1, you would first need to add the deployment to the domain-root (deployment=mydeployment.war) using the the result hash from step-1, after that you can assign it to a server-group i.e. (server-group=trelair-server-group), (deployment=mydeployment.war) - which then will push the deployment to all servers associated with this group.

               

              The address you mentioned does not exist, beside the fact that the syntax is not correct which Tomaz already pointed out.

              • 4. Re: failure to deploy using the http json management api?
                sachindole

                OK. I understood Tomaz and also understood Emanuel. I do have a follow up question for Emanuel before I actually try it out though.

                 

                It sounds like there should be 3 steps to the process. Sounds like I am doing step 1 correctly. I need to correct my "address" in step 2. That seems doable. Is there a third step to do operation named "assign"? I see only "add" on most nodes in the configuration. Attached image is from the jboss cli gui - just for reference to where I am looking for operation names.

                 

                Thank you for your answers so far!!!

                 

                .Capture.PNG

                • 5. Re: failure to deploy using the http json management api?
                  emuckenhuber

                  Yes, adding the deployment to the server-group is what i meant with assigning. Sorry i should have been clearer.

                  • 6. Re: Re: failure to deploy using the http json management api?
                    sachindole

                    Thanks! I was able to make some progress but not all of what I need. I get a "success" response for request to upload content to a server using json management api,

                     

                    Here is my step 1:

                    to /management/add-content, send a post with "file" parameter set to the binary for my war file. I get a success resonse:

                    {"outcome" : "success", "result" : { "BYTES_VALUE" : "34IwM9u5QDmLSTU2rVcV6MbFceY=" }}

                     

                    Step 2: This deploys the uploaded content.

                    {"operation":"add","runtime-name":"testName","address":[{"deployment":"web-1.0-SNAPSHOT.war"}],"content":[{"hash":{"BYTES_VALUE":"34IwM9u5QDmLSTU2rVcV6MbFceY="}}]}
                    
                    

                    This returns a success response:

                    {"outcome" : "success", "result" : null, "server-groups" : null}
                    

                     

                     

                    Step 3:

                    This is where I need some help. How to assign the runtime from step 2 into a specific servergroup? I am able to do this from a cli client, but, I need to do this via the json api. Here is my CLI command that works:

                    /server-group=trelair-server-group/deployment=manual-web-1.0-SNAPSHOT.war/:add(runtime-name=manual-web-1.0-SNAPSHOT.war,enabled=true)
                    
                    

                     

                    I am looking for the json management api equivalent of my CLI step 3.

                     

                    Please help. emuckenhuber ctomc

                     

                    Thank you!

                    • 7. Re: Re: Re: failure to deploy using the http json management api?
                      emuckenhuber
                      {"operation" : "add", "address" : [{ "server-group" : "trelair-server-group" },{ "deployment" : "manual-web-1.0-SNAPSHOT.war" }], "runtime-name" : "manual-web-1.0-SNAPSHOT.war", "enabled" : true}
                      

                       

                      This should be what you had in your CLI command.

                      • 8. Re: Re: Re: failure to deploy using the http json management api?
                        sachindole

                        That did not work. Just gives me a null pointer on the server side:

                         

                        [Host Controller] 21:30:35,494 INFO  [org.jboss.as.repository] (XNIO-1 task-7) JBAS014900: Content added at location C:\Users\sachi_000\dev\tools\WildFly\wildfly-8.0.0.Final-cluster\domain\data\content\df\823033dbb940398b493536ad5715e8c6c571e6\content

                        [Host Controller] 21:31:02,798 ERROR [io.undertow.request] (XNIO-1 task-1) Blocking request failed HttpServerExchange{ POST /management}: java.lang.NullPointerException

                        [Host Controller]       at org.jboss.as.domain.http.server.DomainApiCheckHandler.extractContentType(DomainApiCheckHandler.java:97) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]

                        [Host Controller]       at org.jboss.as.domain.http.server.DomainApiCheckHandler.checkPostContentType(DomainApiCheckHandler.java:82) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]

                        [Host Controller]       at org.jboss.as.domain.http.server.DomainApiCheckHandler.handleRequest(DomainApiCheckHandler.java:71) [wildfly-domain-http-interface-8.0.0.Final.jar:8.0.0.Final]

                        [Host Controller]       at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52) [undertow-core-1.0.0.Final.jar:1.0.0.Final]

                        [Host Controller]       at io.undertow.server.Connectors.executeRootHandler(Connectors.java:168) [undertow-core-1.0.0.Final.jar:1.0.0.Final]

                        [Host Controller]       at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687) [undertow-core-1.0.0.Final.jar:1.0.0.Final]

                        [Host Controller]       at java.util.concurrent.ThreadPoolExecutor.runWorker(Thr

                         

                         

                        How can I increase logging to find out exactly what is wrong with my request? I tried setting org.jboss.dmr to FINEST and also org.jboss.as.domain to FINEST.

                         

                        OR, to repeat my question: I am upto the point where I am able to deploy a war file to the host controller, can anyone show me what is the JSON for assigning the deployment to a specific server group?

                         

                        THANK YOU!    

                        • 9. Re: failure to deploy using the http json management api?
                          sachindole

                          So, I might have found a different, equivalent manner of doing this. Instead of using json api, i am looking into using the CLI api. That seems to convert CLI commands into the json like dmr api (ModelNode) before submitting them to the server. (Very helpfully, it also shows me the json that it constructs).Once I have what I need, I might post the code here for someone else who might also be looking to achieve something similar.

                          • 10. Re: failure to deploy using the http json management api?
                            emuckenhuber

                            This looks like you are missing "application/json" http "Content-Type" as part of the request. Although i am wondering why it would work for the other requests and not this one.

                             

                            BTW. the NPE should be fixed in a newer release of WildFly.