title: How to configure arquillian for remote JBoss 7 container
body: <p><strong>Details:</strong></p>
  
  <ul>
  <li>Ant Build (with a maven extension, this is a solution at my company
  can't change) </li>
  <li>JBoss 7</li>
  <li>Container will be started independently</li>
  </ul>
  
  <p><strong>Setup:</strong></p>
  
  <p>I have a test as follows:</p>
  
  <pre><code>@RunWith(Arquillian.class)
  public class ArquillianArqTest {
  
      @Deployment @TargetsContainer("jbossas_remote")
      public static WebArchive create() {
          return ShrinkWrap.create(WebArchive.class);
      }
  
      @Test
      public void testMyDummy() {
          Assert.assertTrue(Boolean.TRUE);
      }
  
  }
  </code></pre>
  
  <p>I have an arquillian.xml as follows:</p>
  
  <pre><code>&lt;protocol type="jmx-as7"&gt;
          &lt;property name="executionType"&gt;REMOTE&lt;/property&gt;
      &lt;/protocol&gt;
      &lt;configuration&gt;
          &lt;property name="providerUrl"&gt;jnp://127.0.0.1:15090&lt;/property&gt;
          &lt;!--
          &lt;property name="managementAddress"&gt;TEST&lt;/property&gt;
          &lt;property name="managementPort"&gt;TEST2&lt;/property&gt;
          --&gt;
      &lt;/configuration&gt;
  &lt;/container&gt;
  </code></pre>
  
  <p>To my surprise if i try to use the property managementAddress arquillian would simply ignore it. Where as if i use the providerUrl it would try to connect to the defined host:port. 
  => How is this possible? Should it not try to use managementAddress for JBoss 7?</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>The arquillian.xml seems to be picked up the @TargetsContainer also seems to take effect. But nothing happens when i try to run the test. What i mean is that the deploy is not happening it's just hanging there. I am now to be unsure if i use the correct management port. Please see an extract of conf/standalone-dev.xml:</p>
  
  <pre><code>&lt;interfaces&gt;
      &lt;interface name="management"&gt;
          &lt;inet-address value="${jboss.bind.address.management:127.0.0.1}"/&gt;
      &lt;/interface&gt;
      &lt;interface name="public"&gt;
          &lt;any-address/&gt;
      &lt;/interface&gt;
      &lt;interface name="unsecure"&gt;
          &lt;inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/&gt;
      &lt;/interface&gt;
  &lt;/interfaces&gt;
  
  &lt;socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"&gt;
      &lt;socket-binding name="management-native" interface="management" port="15199"/&gt;
      &lt;socket-binding name="management-http" interface="management" port="15190"/&gt;
      &lt;socket-binding name="management-https" interface="management" port="15143"/&gt;
      &lt;socket-binding name="ajp" port="15009"/&gt;
      &lt;socket-binding name="http" port="15080"/&gt;
      &lt;socket-binding name="https" port="15043"/&gt;
      &lt;socket-binding name="jacorb" interface="unsecure" port="15028"/&gt;
      &lt;socket-binding name="jacorb-ssl" interface="unsecure" port="15029"/&gt;
      &lt;socket-binding name="messaging" port="15045"/&gt;
      &lt;socket-binding name="messaging-throughput" port="15055"/&gt;
      &lt;socket-binding name="remoting" port="15047"/&gt;
      &lt;socket-binding name="txn-recovery-environment" port="15012"/&gt;
      &lt;socket-binding name="txn-status-manager" port="15013"/&gt;
      &lt;outbound-socket-binding name="mail-smtp"&gt;
          &lt;remote-destination host="localhost" port="25"/&gt;
      &lt;/outbound-socket-binding&gt;
  &lt;/socket-binding-group&gt;
  </code></pre>
  
  <p><strong>The error:</strong></p>
  
  <blockquote>
    <p>org.jboss.arquillian.container.spi.client.container.LifecycleException:
    Could not connect to container ... Caused by:
    javax.naming.CommunicationException: Could not obtain connection to
    any of these urls: 127.0.0.1:15090 and discovery failed with error:
    javax.naming.CommunicationException: Receive timed out [Root exception
    is java.net.SocketTimeoutException: Receive timed out] [Root exception
    is javax.naming.CommunicationException: Failed to connect to server
    127.0.0.1:15090 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server</p>
  </blockquote>
  
  <p>=> My quesion is what is the correct management port from the above listed ones? </p>
  
  <p><strong>Update Fri Jan 31 4:10 PM</strong></p>
  
  <p>Aha, i think port 15199 will be the correct. I did not notice i get the following error with it:</p>
  
  <blockquote>
    <p>Caused by: javax.naming.CommunicationException: Could not obtain
    connection to any of these urls: localhost:15199 and discovery failed
    with error: javax.naming.CommunicationException: Receive timed out
    [Root exception is java.net.SocketTimeoutException: Receive timed out]
    [Root exception is javax.naming.CommunicationException: Failed to
    retrieve stub from server localhost:15199 [Root exception is
    java.io.StreamCorruptedException: invalid stream header: 0000000C]]
      at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)  at
    org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer.initDeploymentManager(JBossASRemoteContainer.java:204)
      at
    org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer.start(JBossASRemoteContainer.java:87)
      ... 61 more Caused by: javax.naming.CommunicationException: Failed to
    retrieve stub from server localhost:15199 [Root exception is
    java.io.StreamCorruptedException: invalid stream header: 0000000C]    at
    org.jnp.interfaces.NamingContext.getServer(NamingContext.java:268)    at
    org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
      ... 66 more Caused by: java.io.StreamCorruptedException: invalid
    stream header: 0000000C</p>
  </blockquote>
  
  <p>Could it mean i maybe mix versions of libraries?</p>