As JNDI provides no automatic failover mechanism when creating a connection I was about to try and implement one myself. However I have found that when specifying an IP address instead of a server name when creating an initial context JNDI doesn't necessarily use the IP address specified. It seems to do a reverse-dns lookup in the background and use whatever IP is listed first in the Naming tables for that hostname. why oh why does it do that!!
I NEED to specify what IP address it tries to form the connection over. does anyone know a way I can do this or a way of making JNDI retry on the alternate IP address for a hostname?
Background - I need a remote connection to a JNDI registry and the server in question has two nics and IPs. if one IP is inaccessible due to that LAN being dead I need access via the other IP but I don't know how to manage that.
Sorry, I probably didn't explain the situation perfectly.
The client is running as a standalone app that is trying to obtain a reference to an object bound to the JNDI registry within JRun.
I was unsure whether the actual lookup not using the IP I specify (but instead using the first IP specified for that host in the DNS tables) was a JNDI problem/feature I can workaround or whether it was due to the App server driver I'm using.
the JNDI API is mostly implemented by the provider (in this case, JRun). The specification doesn't mention anything about fail-over and stuff, so the way lookup is done is left to the class specified in InitialContext properties' ContextFactory (java.naming.factory.initial). So, if it's not working as expected you should check JRun's implementation. In last case, just try to analise the source code for the InitialContextFactory JRun's implementation to see what's done. JAD can do miracles..
Frederico Melo<br />--------------<br />Software Architect<br />Sun Certified Enterprise Architect for J2EE<br />IBM Rational Unified Process Specialist
I will suppress my every urge. But not this shameless plug: