10 Replies Latest reply on Dec 6, 2002 6:59 PM by Daniel Sieroka

    Reset client InitialContext after server restart

    Daniel Sieroka Newbie

      We have a Java client application running against JBoss. In order to avoid the situation we are in now, we retry lookup failures and reload the InitialContext if that fails. This used to work with another AppServer, but with JBoss, anything looks up with the new InitialContext is null, and therefore you get a NullPointerException on create. Below is some sample code. We are trying to look up a remote session bean after the server is shutdown and restarted. We have to restart the client application for the connections to fucntion properly again.

      Hashtable lHashtable = new Hashtable();
      lHashtable.put("java.naming.factory.initial", initial);
      lHashtable.put("java.naming.factory.url.pkgs", naming);
      lHashtable.put("java.naming.provider.url", url);


      lInitialContext = new InitialContext( lHashtable );

      lHomeObject = lInitialContext.lookup( pLookupName );

      Object obj = ResourceLoader.lookup( pHashtable, "AuditLogCRUD" );
      auditLogCRUDHome = (AuditLogCRUDHome)PortableRemoteObject.narrow( obj, AuditLogCRUDHome.class );
      auditLogCRUD = auditLogCRUDHome.create();

      The last line throws a NPE on create...