8 Replies Latest reply on Sep 24, 2009 5:00 AM by emuckenhuber

    5.1: Programmatically redeploy

    juergen.zimmermann

      I'm using JBossAS 5.1 and redeployment was working fine when basically using this code fragment:

      Context ctx = new InitialContext();
      ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
      DeploymentManager deploymentManager = ps.getDeploymentManager();
      DeploymentProgress redeploy = deploymentManager.redeploy("hska.ear");
      redeploy.run();
      Throwable failure = redeploy.getDeploymentStatus().getFailure();
      ...


      However, today I upgraded to JBossTools 3.1.0.M3 and they moved the deployment location from $JBOSS_HOME/server/default/deploy to ECLIPSE-WORKSPACE/.metadata/.plugins/org.jboss.ide.eclipse.as.core/SERVERNAME/deploy

      So far so good: Deployment is ok, my tests are still running fine - except the programmatically redeployment. I also tried "vfsfile:/.../hska.ear/" instead of "hska.ear", but had no success. Any hint is appreciated!

        • 1. Re: 5.1: Programmatically redeploy
          jaikiran

          What happens? Does it throw any exceptions? Or does it not do anything? Any hints in the server.log?

          • 2. Re: 5.1: Programmatically redeploy
            juergen.zimmermann

            This is the stacktrace:

            15:27:32,749 INFO [DeployHandler] Stop, [vfsfile:/C:/Users/Public/Documents/eclipse-workspace-swe2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy/hska.ear/]
            15:27:32,750 INFO [DeployHandler] Failed to complete command: [redeploy] for deployment: names=[vfsfile:/C:/Users/Public/Documents/eclipse-workspace-swe2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy/hska.ear/], copyContent=true
            org.jboss.profileservice.spi.NoSuchDeploymentException: Failed to find deployment in file: vfsfile:/C:/Users/Public/Documents/eclipse-workspace-swe2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy/hska.ear/
             at org.jboss.system.server.profileservice.repository.AbstractDeploymentRepository.getDeployment(AbstractDeploymentRepository.java:134)
             at org.jboss.profileservice.management.upload.remoting.DeployHandler.scheduleStop(DeployHandler.java:156)
             at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.stop(AbstractDeployHandler.java:308)
             at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.stop(AbstractDeployHandler.java:297)
             at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.redeploy(AbstractDeployHandler.java:348)
             at org.jboss.profileservice.management.upload.remoting.AbstractDeployHandler.invoke(AbstractDeployHandler.java:194)
             at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)
             at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)
             at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)
             at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)
             at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)


            • 3. Re: 5.1: Programmatically redeploy
              emuckenhuber

              So i guess you are not using DeploymentManager to deploy the application?

              • 4. Re: 5.1: Programmatically redeploy
                juergen.zimmermann

                Hmm, I don't know how JBossTools deploy the EAR app in the beginning. The JMX-Console shows that the EAR app was successfully deployed. How should I proceed?

                • 5. Re: 5.1: Programmatically redeploy
                  jaikiran

                  As a workaround try adding

                  file:///C:/Users/Public/Documents/eclipse-workspace-swe2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy

                  as an external deployment folder as explained here http://www.jboss.org/community/wiki/HowtodeploymyapplicationinanexternaldirectoryinJBoss-5

                  That might probably explain why it used to work earlier, since the deploy folder is already picked up by deployment manager (i guess). Give it a try, although i am not completely sure whether it's going to work - haven't looked at profileservice/deployment manager yet.

                  Hmm, I don't know how JBossTools deploy the EAR app in the beginning


                  I think it uses the JMX MainDeployer APIs.


                  • 6. Re: 5.1: Programmatically redeploy
                    emuckenhuber

                    Hmm yeah the workaround could work - this should allow you to use DeploymentManager, although it might pick up the deployment twice.

                    JBossTools uses a JMX facade to add deployments to ProfileService and it seems that those are not exposed to the DeploymentManager properly - so i will have to add a testcase to make sure this is handled in a better way.

                    • 7. Re: 5.1: Programmatically redeploy
                      juergen.zimmermann

                      Switching back to JMX MainDeployer makes redeploy working.

                      It's a pitty that the really nice DeploymentManager cannot be used with JBossTools :-(

                      • 8. Re: 5.1: Programmatically redeploy
                        emuckenhuber

                         

                        "Juergen.Zimmermann" wrote:
                        Switching back to JMX MainDeployer makes redeploy working.

                        It's a pitty that the really nice DeploymentManager cannot be used with JBossTools :-(


                        This should be fixed for 5.2.0.Beta1 - So the deployments added by JBossTools can also be redeployed with DeploymentManager.
                        There is one thing which needs to be done though, as you have to declare a specific profile when using DeploymentManager like:

                         DeploymentManager deployMgr = getDeploymentManager();
                         deployMgr.loadProfile(new ProfileKey("deployment-scanner-profile"));
                         try
                         {
                         DeploymentProgress progress = deployMgr.redeploy(deploymentName);
                         progress.run();
                         assertTrue(progress.getDeploymentStatus().isCompleted());
                         }
                         finally
                         {
                         deployMgr.releaseProfile();
                         }
                        


                        I'll see that we can remove the need to call loadProfile() part for existing deployments in future.