1 Reply Latest reply on Feb 7, 2008 7:28 PM by Ron Sigal

    problem wiht Identity object

    mazz Master

      Suppose I have a box whose hostname is not resolvable via DNS (I know, I know, but for people demo'ing software on a laptop, we've seen it happen). So, I cannot "ping `hostname`" but I can "ping 127.0.0.1".

      Look at NetworkRegistry:

      public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws Exception
       {
       this.mBeanServer = mBeanServer;
       this.objectName = objectName;
       // make sure our identity system property is properly set
       Identity identity = Identity.get(this.mBeanServer);
      ...
      


      Now look at the Identity.get() method it called there:

       if(identities.containsKey(server))
       {
       return (Identity) identities.get(server);
       }
       try
       {
       String serverid = (String) server.getAttribute(new ObjectName("JMImplementation:type=MBeanServerDelegate"), "MBeanServerId");
       Identity identity = new Identity(InetAddress.getLocalHost(), createId(server), serverid);
       identities.put(server, identity);
       return identity;
       }


      It calls InetAddress.getLocalHost() but if that fails (and it will if the local hostname is not resolvable) you can *never* start a NetworkRegistry object.

      If there is an exception here in that call to InetAddress.getLocalHost(), it should fallback and use: InetAddress getByName("127.0.0.1").

      I tried setting "jboss.identity" sysprop to Identity.createUniqueID() but unfortunately, that sysprop isn't used in this class and NetworkRegistry never looks to see if that is set as a fallback.

      I understand that without a resolvable host, it hobbles things - but for demo purposes of software that will ONLY ever run on a single laptop over the loopback network adapter on 127.0.0.1, this should still work without me having to disable things like the NetworkRegistry.