2 Replies Latest reply on Jan 31, 2012 2:54 AM by r0nan

    Remote deploy problem

    andrey.vorobiev

      Hi, guys.

       

      I'm trying to write custom tool for jboss (version 6) remote deploying using this article (http://community.jboss.org/wiki/ProfileServiceDeploymentManagerin5x)

       

      My code is:

       

      package test;
      
      import java.io.File;
      import java.util.Properties;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import org.jboss.deployers.spi.management.deploy.DeploymentManager;
      import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
      import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
      import org.jboss.profileservice.spi.ProfileKey;
      import org.jboss.profileservice.spi.ProfileService;
      
      public class App
      {
          public static void main(String[] args) throws NamingException, Exception
          {
              DeploymentManager deploymentManager = getDeploymentManager();
              deploymentManager.loadProfile(ProfileKey.DEFAULT_PROFILE_KEY);
      
              DeploymentProgress distribute = deploymentManager.distribute("my.ear", (new File("my.ear")).toURI().toURL(), true); 
              distribute.run();
              checkFailed(distribute);
      
              DeploymentProgress start = deploymentManager.start(distribute.getDeploymentID().getRepositoryNames()); 
              start.run();
              checkFailed(start); 
          }
      
          private static void checkFailed(DeploymentProgress progress) throws Exception
          {
              final int timeout = 30;
              DeploymentStatus status = progress.getDeploymentStatus();
              for (int i = 0; i < 30; i++)
              {
                  Thread.sleep(1000);
                  if (status.isCompleted() || status.isFailed())
                  {
                      break;
                  }
                  if (i == timeout - 1)
                  {
                      throw new Exception("Operation timed out");
                  }
              }
              if (status.isFailed())
              {
                  Exception cause = status.getFailure();
                  throw new Exception("Remote action failed: " + status.getMessage()
                          + " (" + cause.getMessage() + ")", cause);
              }
          }
      
          private static DeploymentManager getDeploymentManager() throws NamingException
          {
              Properties env = new Properties();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
              env.put(Context.PROVIDER_URL, "jnp://10.0.1.35:1099");
      
              ProfileService service = (ProfileService) new InitialContext(env).lookup("ProfileService");
              return service.getDeploymentManager();
          }
      }
      
      

       

      I have added following dependencies to my project:

       

      <dependency>
         <groupId>org.jboss.jbossas</groupId>
         <artifactId>jboss-as-client</artifactId>
         <version>6.0.0.Final</version>
         <type>pom</type>
         <exclusions>
             <exclusion>
                 <groupId>com.sun.istack</groupId>
                 <artifactId>istack-commons-runtime</artifactId>
             </exclusion>
             <exclusion>
                 <groupId>woodstox</groupId>
                 <artifactId>wstx-asl</artifactId>
             </exclusion>
             <exclusion>
                 <groupId>ws-commons</groupId>
                 <artifactId>policy</artifactId>
             </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>org.jboss.integration</groupId>
         <artifactId>jboss-profileservice-spi</artifactId>
         <version>6.0.0.Alpha9</version>
         <exclusions>
             <exclusion>
                 <groupId>com.sun.istack</groupId>
                 <artifactId>istack-commons-runtime</artifactId>
             </exclusion>
         </exclusions>
      </dependency>
      

       

      The code above works as expected, i.e. aplication is deployed and started successfully. But my tool doen't exit as expected, i.e. doesn't exit at all. Obtaining thread dump gave me the following:

       

      Full thread dump Java HotSpot(TM) 64-Bit Server VM (17.1-b03-307 mixed mode):

       

      "WorkerThread#0[10.0.1.35:35887]" prio=5 tid=137042000 nid=0x13c138000 in Object.wait() [13c137000]

         java.lang.Thread.State: WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <1084b0000> (a org.jboss.remoting.transport.socket.ServerThread)

                at java.lang.Object.wait(Object.java:485)

                at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:286)

                - locked <1084b0000> (a org.jboss.remoting.transport.socket.ServerThread)

       

       

      "AcceptorThread[ServerSocket[addr=/10.0.1.177,port=0,localport=8357]]" prio=5 tid=132a43800 nid=0x13c035000 runnable [13c034000]

         java.lang.Thread.State: RUNNABLE

                at java.net.PlainSocketImpl.socketAccept(Native Method)

                at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:390)

                - locked <1084c8ed0> (a java.net.SocksSocketImpl)

                at java.net.ServerSocket.implAccept(ServerSocket.java:453)

                at java.net.ServerSocket.accept(ServerSocket.java:421)

                at org.jboss.remoting.transport.socket.SocketServerInvoker.accept(SocketServerInvoker.java:1145)

                at org.jboss.remoting.transport.socket.SocketServerInvoker.access$200(SocketServerInvoker.java:69)

                at org.jboss.remoting.transport.socket.SocketServerInvoker$AcceptThread.run(SocketServerInvoker.java:1056)

       

       

      "ServerSocketRefresh" daemon prio=5 tid=132a4d000 nid=0x13bf32000 in Object.wait() [13bf31000]

         java.lang.Thread.State: WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <1084e1ca0> (a java.lang.Object)

                at java.lang.Object.wait(Object.java:485)

                at org.jboss.remoting.transport.socket.SocketServerInvoker$ServerSocketRefresh.run(SocketServerInvoker.java:880)

                - locked <1084e1ca0> (a java.lang.Object)

       

       

      "RMI Scheduler(0)" daemon prio=5 tid=1330f8000 nid=0x13bc86000 waiting on condition [13bc85000]

         java.lang.Thread.State: TIMED_WAITING (parking)

                at sun.misc.Unsafe.park(Native Method)

                - parking to wait for  <10da63bc0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)

                at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:198)

                at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2025)

                at java.util.concurrent.DelayQueue.take(DelayQueue.java:164)

                at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:609)

                at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:602)

                at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)

                at java.lang.Thread.run(Thread.java:680)

       

       

      "GC Daemon" daemon prio=2 tid=101d64800 nid=0x13b9cf000 in Object.wait() [13b9ce000]

         java.lang.Thread.State: TIMED_WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <10d5f82d0> (a sun.misc.GC$LatencyLock)

                at sun.misc.GC$Daemon.run(GC.java:100)

                - locked <10d5f82d0> (a sun.misc.GC$LatencyLock)

       

       

      "RMI RenewClean-[10.0.1.35:1098]" daemon prio=5 tid=101c49800 nid=0x138509000 in Object.wait() [138508000]

         java.lang.Thread.State: TIMED_WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <10d5f82e8> (a java.lang.ref.ReferenceQueue$Lock)

                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)

                - locked <10d5f82e8> (a java.lang.ref.ReferenceQueue$Lock)

                at sun.rmi.transport.DGCClient$EndpointEntry$RenewCleanThread.run(DGCClient.java:516)

                at java.lang.Thread.run(Thread.java:680)

       

       

      "Poller SunPKCS11-Darwin" daemon prio=1 tid=101f2b000 nid=0x138101000 waiting on condition [138100000]

         java.lang.Thread.State: TIMED_WAITING (sleeping)

                at java.lang.Thread.sleep(Native Method)

                at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:692)

                at java.lang.Thread.run(Thread.java:680)

       

       

      "Low Memory Detector" daemon prio=5 tid=10281e800 nid=0x132201000 runnable [00000000]

         java.lang.Thread.State: RUNNABLE

       

       

      "CompilerThread1" daemon prio=9 tid=10281d800 nid=0x13178d000 waiting on condition [00000000]

         java.lang.Thread.State: RUNNABLE

       

       

      "CompilerThread0" daemon prio=9 tid=10281d000 nid=0x13168a000 waiting on condition [00000000]

         java.lang.Thread.State: RUNNABLE

       

       

      "Signal Dispatcher" daemon prio=9 tid=10281c000 nid=0x131587000 waiting on condition [00000000]

         java.lang.Thread.State: RUNNABLE

       

       

      "Surrogate Locker Thread (CMS)" daemon prio=5 tid=10281b800 nid=0x131484000 waiting on condition [00000000]

         java.lang.Thread.State: RUNNABLE

       

       

      "Finalizer" daemon prio=8 tid=10196c000 nid=0x13118c000 in Object.wait() [13118b000]

         java.lang.Thread.State: WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <10b434dc0> (a java.lang.ref.ReferenceQueue$Lock)

                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)

                - locked <10b434dc0> (a java.lang.ref.ReferenceQueue$Lock)

                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)

                at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

       

       

      "Reference Handler" daemon prio=10 tid=10196b800 nid=0x131089000 in Object.wait() [131088000]

         java.lang.Thread.State: WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <10b4b7040> (a java.lang.ref.Reference$Lock)

                at java.lang.Object.wait(Object.java:485)

                at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)

                - locked <10b4b7040> (a java.lang.ref.Reference$Lock)

       

       

      "main" prio=5 tid=102801000 nid=0x100501000 in Object.wait() [1004ff000]

         java.lang.Thread.State: WAITING (on object monitor)

                at java.lang.Object.wait(Native Method)

                - waiting on <1084c8e08> (a org.jboss.remoting.transport.socket.SocketServerInvoker$AcceptThread)

                at java.lang.Thread.join(Thread.java:1210)

                - locked <1084c8e08> (a org.jboss.remoting.transport.socket.SocketServerInvoker$AcceptThread)

                at org.codehaus.mojo.exec.ExecJavaMojo.joinThread(ExecJavaMojo.java:409)

                at org.codehaus.mojo.exec.ExecJavaMojo.joinNonDaemonThreads(ExecJavaMojo.java:399)

                at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:303)

                at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)

                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)

                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)

                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)

                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)

                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)

                at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)

                at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)

                at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)

                at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:153)

                at org.apache.maven.cli.MavenCli.execute(MavenCli.java:451)

                at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:188)

                at org.apache.maven.cli.MavenCli.main(MavenCli.java:134)

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                at java.lang.reflect.Method.invoke(Method.java:597)

                at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)

                at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)

                at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

                at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

       

      As far as I undestand embedded instance of JBoss is started locally and accepts socket connections.

       

      So my question is: How can I prevent such behaviour, i.e. to avoid starting local jboss instance.