UniqueKeyGenerator should be able to work without network cards #62

snazy opened this Issue Jan 15, 2013 · 4 comments


None yet

2 participants


I just changed my WLAN connection, started my app while my mac had no WLAN connected and got "RuntimeException: Call to InetAddress.getLocalHost().getHostname() == localhost. ...."

No idea yet how to solve this, but another thing I would like to see to be configurable in NoSqlEntityManagerFactory.

Just imagine that a customer has some data centers and some racks in each data center and a FQDN structure like this:

(off topic: @deanhiller now that I've seen UniqueKeyGenerator code I know what you meant with currentTimeMillis+1 ;-) )


yes, linux needs to be configured correctly to give you the actual localhost or use of UniqueKeyGenerator fails to work.

hmmm, my email had said "not thread safe" but I don't see that here so maybe you deleted that part and see the synchronized keyword.

it is common to have linux not setup right and java getLocalHost returns instead of ht local ip actually and this is VERY VERY bad when it comes to installing cassandra and lots of servers actually. on windows it always seems to do it right and I think even on mac it does but linux seems to vary between returning and the actual ip. A quick way is to modify /etc/hosts to fix it but there is another way to fix it too that seemed better that I can't recall.


OH, and yes, without network cards, it should be able to work though I need to think more about this one as we really want to prevent customers from booting up 4 servers thinking that UniqueKeyGenerator is working when it may not be working because of the bad linux config. We need to think about this more as I want the exception to tell users still but I guess need a configurable way around it as well then.


("not thread safe" : shame on me - too late to recognize synchronized keyword)

Think of MacBook users: if no networks (LAN & WLAN) are available, NetworkInterface will only return the loopback adapter. On Win NetworkInterface returns all interfaces - but non-running interfaces have no mac address (as far as I remember).

And think of servers with multiple network connections - which hostname to use?? InetAddress.getLocalHost(), any of the hostnames taken from NetworkInterface? I don't know. I prefer to configure it during rollout.


yes, I agree it should be configurable and we can use that ticket for that....I also like it automatic in some cases but must give an exception if I can't auto assign it because yes in the case of multiple nics and multiple hostnames I don't know which one they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment