Getting java.net.SocketException when trying to start a multicast provider:
2013-09-11 11:45:44,204 [main] ERROR net.sf.ehcache.distribution.Mul
You need to add certain configurations to Java VM before you can join a Multicast socket in any machine.
First add this line before attempting any connection to make sure you will get only IPv4 addresses:
System.setProperty("java.net.preferIPv4Stack", "true");
In most of the cases your computer has more than one network interface, so you need to choose the correct one:
Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration addressesFromNetworkInterface = networkInterface.getInetAddresses();
while (addressesFromNetworkInterface.hasMoreElements()) {
InetAddress inetAddress = addressesFromNetworkInterface.nextElement();
if (inetAddress.isSiteLocalAddress()
&& !inetAddress.isAnyLocalAddress()
&& !inetAddress.isLinkLocalAddress()
&& !inetAddress.isLoopbackAddress()
&& !inetAddress.isMulticastAddress()) {
socket.setNetworkInterface(NetworkInterface.getByName(networkInterface.getName()));
}
}
}