In order to recover the HA proxy, the
RetryInterceptor does a lookup in JNDI. This means that internally it creates a new InitialContext and does a JNDI lookup. For that lookup to succeed, the InitialContext needs to be configured properly to find your naming server. The RetryInterceptor will go through the following steps in attempting to determine the proper naming environment properties:
- It will check its own static
retryEnvfield. This field can be set by client code via a call toRetryInterceptor.setRetryEnv(Properties). This approach to configuration has two downsides: first, it reduces portability by introducing JBoss-specific calls to the client code; and second, since a static field is used only a single configuration per VM is possible. - If the
retryEnvfield is null, it will check for any environment properties bound to aThreadLocalby theorg.jboss.naming.NamingContextFactoryclass. To use this class as your naming context factory, set thejava.naming.factory.initial=org.jboss.naming.NamingContextFactoryproperty in yourjndi.properties. The advantage of this approach is use oforg.jboss.naming.NamingContextFactoryis simply a configuration option in yourjndi.propertiesfile, and thus your Java code is unaffected. The downside is the naming properties are stored in aThreadLocaland thus are only visible to the thread that originally created anInitialContext. - If neither of the above approaches yield a set of naming environment properties, a default
InitialContextis used. If the attempt to contact a naming server is unsuccessful, by default theInitialContextwill attempt to fall back on multicast discovery to find an HA-JNDI naming server. See Chapter 18, Clustered JNDI Services for more on multicast discovery of HA-JNDI.