Version 1

    If you are running Ubuntu 10.10, read this FAQ!




    If you're running your tests with the remote JBoss AS container adapter, you may encounter the following socket connection error (assume here your computer's hostname is myhost):


    Caused by: org.jboss.arquillian.spi.DeploymentException: Failed to deploy test.war
       at org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer.deploy(
       at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(
       at org.jboss.arquillian.impl.handler.ContainerDeployer.callback(
       ... 18 more
    Caused by: java.lang.RuntimeException: Can not get connection to server.
          Problem establishing socket connection for InvokerLocator [socket://myhost: 63209/]
       at org.jboss.arquillian.container.jbossas.remote_6.JBossASRemoteContainer.deploy(
       ... 21 more


    This started happening on Ubuntu 10.10 (and perhaps other versions of Linux). Network Manager overwrites hostname assignments in /etc/hosts when obtaining an address from a DHCP server. In particular, it:



    • inserts the entry for the dynamic IP address in the first line
    • removes the hostname from
    • puts localhost.localdomain before localhost in the entry (may just be an annoyance)


    The beginning of the /etc/hosts file ends up looking like this (followed by some IPv6 entries):

  myhost localhost.localdomain localhost
    ::1 myhost localhost6.localdomain6 localhost6 myhost


    What it comes down to is that Network Manager should not be messing with this file as it wrecks havoc on servers, such as JBoss AS, bound to these addresses.




    The only solution we've been able to figure out is to use a cron job as the root user to fixe the file when it gets messed up.


    First, create the correct version of /etc/hosts and stick it somewhere, such as /etc/hosts.fixed, and populate it with the following contents (replace myhost with the hostname of your computer, as reported by the hostname command, and the correct IP assignment, as reported by ipconfig):


    /etc/hosts.fixed myhost localhost localhost.localdomain
    ::1 myhost localhost6 localhost6.localdomain6 myhost
    ## (optional entry); update if assigned a new address from DHCP myhost
    ## The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost  ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts


    Next, create a script named /etc/ to replace the /etc/hosts file if Network Manager screws it up:



    if [ `grep -c NetworkManager /etc/hosts` -eq 1 ]; then
       cp /etc/hosts.fixed /etc/hosts


    Finally, setup a cron job to run this script as often as you like. We recommend every couple of minutes.


    */3 * * * * /etc/


    Once the /etc/hosts file is corrected, restart JBoss AS and run the tests again. Your socket connection error should be gone!