I wrote following EJB:
@Singleton
@LocalBean
@Startup
public class Starter {
private static final Logger logger = Logger.getLogger("lab");
@PostConstruct
public void init() throws Exception {
for (final Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
final NetworkInterface iface = en.nextElement();
if (iface.isUp()) {
logger.info(iface);
}
}
}
}
On deploy this logs like:
name:lo (Software Loopback Interface 1)
name:net0 (WAN Miniport (SSTP))
name:net1 (WAN Miniport (L2TP))
name:net2 (WAN Miniport (PPTP))
name:ppp0 (WAN Miniport (PPPOE))
name:eth0 (WAN Miniport (IPv6))
name:eth1 (WAN Miniport (Network Monitor))
name:eth2 (WAN Miniport (IP))
name:net5 (Intel(R) Wireless WiFi Link 4965AGN)
name:eth7 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport)
name:eth8 (VirtualBox Host-Only Ethernet Adapter)
name:net20 (Intel(R) Wireless WiFi Link 4965AGN-Netmon Lightweight Filter Driver-0000)
name:eth10 (VirtualBox Host-Only Ethernet Adapter-Netmon Lightweight Filter Driver-0000)
name:eth11 (VirtualBox Host-Only Ethernet Adapter-QoS Packet Scheduler-0000)
name:eth12 (VirtualBox Host-Only Ethernet Adapter-WFP LightWeight Filter-0000)
name:eth13 (WAN Miniport (IPv6)-QoS Packet Scheduler-0000)
name:eth14 (WAN Miniport (IP)-QoS Packet Scheduler-0000)
name:eth15 (WAN Miniport (Network Monitor)-Netmon Lightweight Filter Driver-0000)
name:eth16 (WAN Miniport (Network Monitor)-QoS Packet Scheduler-0000)
name:net21 (Intel(R) Wireless WiFi Link 4965AGN-Native WiFi Filter Driver-0000)
name:eth20 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-Netmon Lightweight Filter Driver-0000)
name:eth21 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-QoS Packet Scheduler-0000)
name:eth22 (Intel(R) Wireless WiFi Link 4965AGN - VirtualBox Bridged Networking Driver Miniport-WFP LightWeight Filter-0000)
Which is not valid. Output from this same loop running on J2SE runtime looks like:
name:lo (Software Loopback Interface 1)
name:net5 (Intel(R) Wireless WiFi Link 4965AGN)
name:eth8 (VirtualBox Host-Only Ethernet Adapter)
Is this an application server issue? I'm using JBoss EAP 6.1.0 GA (which is built on AS 7). How to get valid list of NetworkInterfaces running up without opening connection on each? Besides that, I want to known which one supports multicast, but this is always true
too.
Repo
I have been created repo at github with Idea's project, compiled ear and logs for both jboss and pure jdk's running. It's contains also used configuration file and list of dynamically loaded libraries.
The difference is a result of using the "-Djava.net.preferIPv4Stack=true" commandline option, you probably start the JBoss JVM with this option set. When starting the standalone program with this option, it will give you the same results.
As to why exactly this happens I'm still searching. So far I've come to the conslusion something gets confused when you have multiple interfaces on the same physical device, where some have IPv6 enabled and some have it disabled. This "something" might be the Windows, the JVM or the NetworkInterface class.
Some information about the option and how IPv4 and IPv6 work within the JVM in the Networking IPv6 User Guide from Oracle.
Google Search "java.net.preferIPv4Stack isUp" leads to an OpenJDK bug report which actually states the ifUp() method may not work correctly in some cases where IPv6 is disabled on the interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With