1. glassfish
  2. GLASSFISH-16344

Unable to start two domains on system where IPs are aliased to the same network interface.


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 3.1
    • Fix Version/s: 4.0
    • Component/s: admin
    • Labels:


      I'm trying to start two different domains on the same system, but have
      run into some issues that I hope you may be able to help with.

      Firstly, the machine I'm working with has a single NIC. The IP address
      is I've created an IP alias to this NIC,

      With a simple perl script, I'm able to bind the same port on either
      address (i.e. bind a server on and

      So, this confirms I have a basic working configuration.

      Now, I create a second domain, domain2, and update all the appropriate
      addresses to refer to I update domain1 in a similar
      fashion and set the addresses to

      I start domain1 using the following:

      asadmin --host start-domain --verbose domain1

      I can see in the log that is being used as expected.
      However, when I attempt to start domain2 using:

      asadmin --host start-domain --verbose domain2

      I receive the following error:

      There is a process already using the admin port 4848 – it
      probably is another instance of a GlassFish server.

      I've looked through the code and came across this:

      private static boolean isPortFreeServer(int port) {
      // check 3 different ip-port combinations.
      // Amazingly I have seen all 3 possibilities – so just
      checking on
      // is not good enough.
      // Usually it is the – but JMS (default:7676)
      // only returns false from the "localhost":port combination.
      // We want to be aggressively disqualifying ports rather than
      the other
      // way around

      try {
      byte[] allZero = new byte[]

      {0, 0, 0, 0}

      InetAddress add = InetAddress.getByAddress(allZero);

      if (isPortFreeServer(port, add) == false)
      return false; // return immediately on "not-free"

      add = InetAddress.getLocalHost();

      if (isPortFreeServer(port, add) == false)
      return false; // return immediately on "not-free"

      add = InetAddress.getByName("localhost");

      return isPortFreeServer(port, add);
      catch (Exception e)

      { // If we can't get an IP address then we can't check return false; }


      which is invoked by StartServerHelper to ensure the port isn't already

      In my environment, the second isPortFreeServer() fails as
      InetAddress.getLocalHost() in this
      case returns While this return value is correct, this
      appears to be a false positive.

      Wouldn't it make sense, in the case when an explicit host and/or port is passed to asadmin
      to perform the validation against those arguments instead of against the local addresses?



          • Assignee:
            Byron Nevins
            Ryan Lubke
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: