3 Replies Latest reply on Aug 25, 2012 9:58 AM by Wolf-Dieter Fink

    Problem with CLI Undeploy

    sudhananthan B Newbie

      I've started jboss 7  server with following configuration

       

      <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">

                  <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-enabled="true" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false"/>

      </subsystem>

       

      so the deployment of modules gets started only when user placed marker file (or) initiated it via command line.

       

      I deployed my myapp.ear application programatically(using CLI) when the server gets started. I achieved this by writing a service by extending org.jboss.msc.service.Service, created "deploymentController.jar" and placed under standalone/deployments/ for controlling "myapp.ear" deployment.

      Note: deploymentController.jar will be deployed automatically when server starts(marker file for specific jar is placed).

       

      the deployment code is something like :

       

                 client = ModelControllerClient.Factory.create(InetAddress.getLocalHost().getHostAddress(), 9999);

                  manager = ServerDeploymentManager.Factory.create(client);

                  final DeploymentPlanBuilder builder = manager.newDeploymentPlan();

                  final DeploymentPlan plan;

                  FileInputStream archile = new FileInputStream(jbossDeploymentPath+"myapp");

                  plan = builder.add("clust.ear",archile).deploy("clust.ear").build();

       

      And above code is written in start() method of myService which extends org.jboss.msc.service.Service which will automatically called when deploymentController.jar gets deployed.

       

      The issue is with Undeploying of "myapp.ear". I want to undeploy  "myapp.ear" when server gets down, i wrote undeploy logic similar to above code  in stop() method of myService which extends org.jboss.msc.service.Service. But the connection gets closed when control moves to stop() method so i it fails. 

       

      CLI deploy not gets undeployed automatically when server gets down.

       

      My requirement is to undeploy the deployed modules i.e made via CLI, when the server gets down.

       

      please give me the solution to achieve this in a gracefull manner.

       

      Thanks a lot in advance,

      Sudhananthan B.

        • 1. Re: Problem with CLI Undeploy
          Wolf-Dieter Fink Master

          I'm not sure that I've get your problem.

           

          What version of AS do you use?

          What you want to achieve? Could you describe it? It looks like that you don't want the deployment scanner at all.

          Does it works if you deploy via jboss-cli instead of your own programatic solution?

          • 2. Re: Problem with CLI Undeploy
            sudhananthan B Newbie

            Hi Wolf-Dieter Fink,

            Wolf-Dieter Fink wrote:

             

            I'm not sure that I've get your problem.

             

            What version of AS do you use?

            Jboss as 7.1.1 version

             

            What you want to achieve? Could you describe it? It looks like that you don't want the deployment scanner at all.

            I want to  initiate deployment programatically via my singleton clustered service. So that if multiple nodes are running in cluster, deployment will only happen in the  one node which is elected as singleton service provider. This is to achieve MASTER-SLAVE HASingleton model as in jboss 5.

             

             

            Does it works if you deploy via jboss-cli instead of your own programatic solution?

            Deployment via jboss-cli works fine. And i've no problem with deployment at all. I just want to know feasibility of undeploying the deployed(that  was made through CLI) module  when server shutdown initiated.

             

            Please let me know if you need more details, if so i'll send the sample project for your clarification.

             

            Thanks

            Sudhananthan B.

            • 3. Re: Problem with CLI Undeploy
              Wolf-Dieter Fink Master

              You can use the management API to deploy files with a SingletonService.

              There is a quickstart (#76) for SingletonService see the documentation .

               

              If you use the mngmt API you might scan the filesystem outside the deployment folder, you might want to use the normal deployment, also it sounds error prone to me that you have to add the marker files (someone might remove it by accident).

              If you add a deployment you can set the flag 'non-persistent' so it is not added to the standalone*.xml config to be permanent and if the server restart it will no longer depoyed.

               

              You can have a look into the deployment scanner classes here https://github.com/jbossas/jboss-as/tree/master/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner

               

              Also there is a issue that the singleton service is not correct handled after cluster splitt/merge see AS7-5218