NamingContext#localServer was null because jnp-client.jar was included in the WAR so the NamingContext class was loaded by the WAR class loader instead of retrieved from the system classloader. NamingContext#localServer is a static variable and is set by NamingBeanImpl on startup of the server and is obviously only set on the NamingContext class that is loaded by the system classloader.
I still have some questions on this issue though:
- Why is broadcast discovery enabled by default?
- It seems the CommunicationException should be replaced with an exception that is more intuitive. The problem in this case is that InitialContext couldn't lookup an object as is couldn't get a hold of the naming server which is not at all made clear by the exception.