10 Replies Latest reply on Jan 10, 2002 6:15 PM by adrian.brock

    remote hot-deploy

    zeminhu

      I am trying to write a remote hot-deploy tool for JBoss, I could not find this capability from Jboss doc, could anyone tell me if JBoss is capable of doing this? If yes, what APIs should I look for? Sample code are appreciated. If not, does JBoss have plans to add this feature yet? Thanks.

      Zemin

        • 1. Re: remote hot-deploy

          You can do this using JMX.

          http://server.running.jboss:8082

          find the J2eeDeployer service

          DefaultDomain:service=J2eeDeployer on 2.4
          JBOSS-SYSTEM:service=J2eeDeployer on 3.0 alpha
          jboss.j2ee:service=J2eeDeployer on 3.0 current CVS

          (confusing? - the last one is best, I digress)

          click on it and find the deploy operation.

          Type in http://another.remote.machine/myApplication.jar
          and press deploy.

          This generates the request

          http://server.running.jboss:8082/InvokeAction//jboss%2Ej2ee%3Aservice%3DJ2eeDeployer/action=deploy?param0%2Bjava.lang.String=http%3A%2F%2Fanother.remote.machine%2FmyApplication.jar

          Job done.

          This uses the html (sic! should be http) adaptor
          provided by Sun.
          In 3.0 there's also an RMI JMX adaptor.

          You can write jmx adaptors using whatever
          protocol you desire.

          I'm waiting for
          org.jboss.carrier.pigeon.adaptor.PigeonAdaptorService :-)

          Regards,
          Adrian

          • 2. Re: remote hot-deploy
            zeminhu

            Thank you so much. I just did that.
            I am talking about doing it programmingly. There two approach I could use from here:
            1. parameterize the ip of AppServer and target machine but keep other things of the URL exactly the same;
            2. get remote reference of this J2eeDeployer() and pass the file the I want to deploy.
            It seems second choice is more elegant, but I don't how to get the remote reference of J2eeDeployer. Do you know how or any other suggestions?
            You talked about JMX adaptors and RMI JMX adaptor, could you shed some light on this approach? I am only interested in programming approach. Thank you.

            Zemin

            • 3. Re: remote hot-deploy

              Programatically it is easy you are just an http client
              like a browser.

              WARNING: Completely untested code, not even proof read
              let alone compiled, but it has the basic idea.

              String theRequestURL = formatURL(jbossServer, deploymentURL);
              URL url = new URL(theRequestURL);
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              if (conn.getResponseCode() != HTTPURLConnection.HTTP_OK)
              System.out.println(conn.getResponseMessage())
              else
              System.out.println("Ok");
              conn.disconnect();

              You probably want to do a more graceful disconnect.

              Regards,
              Adrian

              • 4. Re: remote hot-deploy
                zeminhu

                Thanks again. I see what you are saying.
                I just want to verify with you that the my URL construction is right:
                http://appserver:8082/InvokeAction//J2EE:service=J2eeDeployer/action=deploy?param0?java.lang.String=targetJarURL

                My another qustion would be where in the URL could I put in id/password?

                Thanks.

                Zemin

                • 5. Re: remote hot-deploy

                  Oops forget to answer the second part of your question.

                  There is some example code in the 3.0 testsuite for
                  the jmx adaptor.

                  http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jbosstest/src/main/org/jboss/test/jmx/

                  One part includes hot-deploying of the new 3.0 services.

                  Another probably of more interest to you
                  Registers a ConnectionFactoryLoader
                  Uses that to create new DataSource
                  Then deploys a session bean. Although it does it from
                  a local file, the idea is the same.

                  Just use a remote server name in the link below
                  and deploy an http url.

                  http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jbosstest/src/main/org/jboss/test/JBossTestServices.java?annotate=1.9

                  If you know JMX it shouldn't be hard
                  to figure-out how to do this for the J2eeDeployer.

                  Regards,
                  Adrian

                  • 6. Re: remote hot-deploy

                    User name and password is rubbish over http.

                    http://user:password@not.very.protected.site/etc

                    which is nearly what gets sent over the network.

                    Of course you could always use ssl, but I don't
                    think Sun's http adaptor supports that.
                    I could be wrong??

                    What about a webapp on JBoss that
                    uses ssl and proxies the requests.

                    You really need to make sure port 8082 cannot be
                    accessed externally. Otherwise someone could do
                    some real damage!
                    I think I'll stop the naming service :-(

                    The rmi or ejb adaptor gives better security options.

                    But security isn't really my forte.

                    Regards,
                    Adrian

                    • 7. Re: remote hot-deploy

                      Ok, whats the escape character to turn of smilies.
                      That should be colon p, not :P

                      Regards,
                      Adrian

                      • 8. Re: remote hot-deploy

                        I see capitals ;-)

                        Regards,
                        Adrian

                        • 9. Re: remote hot-deploy
                          zeminhu

                          Thank you so much.
                          Now I have to think about how I really want to implement the tool.
                          I could install my RMI/SSL server to copy the files over to the target host and deploy it, but problem is this pre-requisite is really an over-kill only for file transfer which is not smart. I was expecting JBoss could provide client side API that allow users to do deployment, something like:
                          deploy(appServerURL, targetFileURL, userName, password);
                          then JBoss takes care about SSL and user authentication, which is not that hard to do. If Jboss need me to contribute this part, I would like to do it.

                          zemin_hu@hotmail.com

                          Zemin

                          • 10. Re: remote hot-deploy

                            Go ahead.

                            You might want to get some input
                            from the security forum about how best to do the
                            security. Everybody's got there own preferred methods,
                            so make it flexible.

                            Have a look at broadening the scope into creating
                            some nice (remote) admin tools using the
                            RMI or EJB adaptor.
                            If you're going to take this on I'd ask around first
                            to see what other people are doing, its always useful to get other peoples input and ideas. It avoids
                            duplication as well.

                            This has gone a bit off-topic for the EJB forum.
                            It's over an hour since I mentioned session
                            beans :-)

                            Regards,
                            Adrian