We are currently on a road trip to watch opening weekend of College Football. I’m trying to get a little work done in the car – and by that, probably a whole hours worth.
Im working on a Java application on my Macbook, which communicates with a MySQL backend. Due to various dependencies, MySQL runs inside an Ubuntu VM via Virtualbox. Normally this setup works great – communicating with the database is fast, the VM starts up and shuts down in a second (thanks to the SSD in the Macbook), but not this time. Whenever Hibernate attemted to open a connection, it would take about 30 seconds before either timing out, or eventually connecting.
I know that Hibernate likes to use XML for a lot of its configuration, so my first suspect was that it was trying to validate some internal
XML document via an external DTD lookup. The debug log did not make it look like that was the case, so I dug a little bit on my iPhone.
I found one article that referenced a similar setup – Oracle running inside a VM. It turns out that if the VM’s network adaptor is running
in NAT mode, and the host is offline, lookups can take 30+ seconds to resolve. My VM actually has two network adaptors – one via NAT, one “Host Only”
The solution? I disabled the NAT adaptor, rebooted the VM, waited for it to fail DHCP, and all was well.
The setup isn’t perfect, it isn’t pretty, but at least I was able to get it working while in the car.