Connection refused error on EJB client when restarting WebSphere Application Server with JNDI Caching enabled
 Technote (troubleshooting)
 
Problem(Abstract)
If you are running a Java™ EJB™ client to an IBM® WebSphere® Application Server with Java Naming and Directory Interface (JNDI™) caching enabled, and you stop and restart the application server with the client running, you might see Connection Refused errors on the client.
 
Cause
The client contains cache entries from the Application Server instance that ended, resulting in inconsistencies in the cached JNDI data when the Application Server restarts. Because the port is dynamically assigned, the Application Server is likely to select a different port during reboot when the client still has JNDI cached information for the server before it was rebooted.
 
Resolving the problem

Scenario:

1. Both WebSphere Application Server (server1) and a simple client (server2) are running without any problems.

2. Server1 is brought down and back up again without restarting the client.

3. Client on server2 fails to run with the following errors:

Java RemoteException -- System Level
java.rmi.RemoteException: CORBA TRANSIENT 0x4942f301 No; nested        
exception is:                                                          
org.omg.CORBA.TRANSIENT: Connection refused:host=192.168.1.100,port=55111
vmcid: IBM  minor code: 301  completed: No                              
at                                                                    
com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl
java:258)                                                              
at javax.rmi.CORBA.Util.mapSystemException(Util.java:83)              
at com.gang.test._HelloWLMHome_Stub.create(_HelloWLMHome_Stub.java:222)
at com.gang.test.client.TestUid.main(TestUid.java:54)                  
Caused by: org.omg.CORBA.TRANSIENT: Connection                          
refused:host=192.168.1.100,port=55111  vmcid: IBM  minor code: 301        
completed: No                                        

The client needs to clear the JNDI cache. There are three JNDI cache properties; by default it is set to populated.
  • Populated
    Use a cache with the specified name. If the cache already exists, leave existing cache entries in the cache; otherwise, create a new one.
  • Cleared
    Use a cache with the specified name. If the cache already exists, clear all cache entries from the cache; otherwise, create a new cache.
  • None
    Do not cache. If this option is specified, the cache name is irrelevant. Therefore, this option will not disable a cache that is already associated with other InitialContext instances. The InitialContext that is initiated is not associated with any cache.

In this scenario, there are two options. Set the cache property to None or Cleared. Setting the property to none can affect performance because there are no cached entries. To set, follow this example:

com.ibm.websphere.naming.jndicache.cacheobject=none

Set the property on the client in one of the following ways.
  • To set properties through the command line, type the string value as indicated in this example:

    java -Dcom.ibm.websphere.naming.jndicache.cacheobject=none

  • To set properties in a file, create a text file listing the properties. For example:

    ...
    com.ibm.websphere.naming.jndicache.cacheobject=none
    ...

  • To set properties in a Java program, use the following PROPS.JNDI_CACHE* Java constants, defined in com.ibm.websphere.naming.PROPS:

    public static final String JNDI_CACHE_OBJECT = "com.ibm.websphere.naming.jndicache.cacheobject";
    public static final String JNDI_CACHE_OBJECT_NONE      = "none";
    public static final String JNDI_CACHE_OBJECT_POPULATED = "populated";
    public static final String JNDI_CACHE_OBJECT_CLEARED   = "cleared";
    public static final String JNDI_CACHE_OBJECT_DEFAULT   = JNDI_CACHE_OBJECT_POPULATED;

    public static final String JNDI_CACHE_NAME = "com.ibm.websphere.naming.jndicache.cachename";
    public static final String JNDI_CACHE_NAME_DEFAULT = "providerURL";

    public static final String JNDI_CACHE_MAX_LIFE = "com.ibm.websphere.naming.jndicache.maxcachelife";
    public static final int    JNDI_CACHE_MAX_LIFE_DEFAULT = 0;

    public static final String JNDI_CACHE_MAX_ENTRY_LIFE = "com.ibm.websphere.naming.jndicache.maxentrylife";
    public static final int    JNDI_CACHE_MAX_ENTRY_LIFE_DEFAULT = 0;

  • To clear the cache, the exception handler in the application code will need to clear the JNDI cache. To set a property in your program, type the following:

    env.put(PROPS.JNDI_CACHE_OBJECT, PROPS.JNDI_CACHE_OBJECT_CLEARED);
    InitialContext ic = new InitialContext(env);
 
Related information
Search the Information Center for JNDI caching
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > JNDI/Naming
Operating system(s): Windows
Software version: 6.1.1
Software edition:
Reference #: 1153215
IBM Group: Software Group
Modified date: Jan 15, 2008