3 Replies Latest reply on Jun 28, 2004 5:34 AM by Marc Golinelli

    EJB creation fails after server restarts

    Marc Golinelli Newbie

      Hi,

      We are using the service locator pattern (cache enabled) in a tomcat standalone and get the following exception after jboss restarts:
      java.rmi.NoSuchObjectException: no such object in table

      Any idea ?
      Do we have to change something in the invoker proxy binding to enable the home cache feature of our service locator ?

      Regards,
      FrereTuck



        • 1. Re: EJB creation fails after server restarts
          jamesstrachan Newbie

          I have tested this on another J2EE server (no names, no pack drill) and found that the home interface appears to contain data specific to the server instance - perhaps a memory address or object within the server.

          Stopping and restarting the server makes this reference invalid, leading to the error that you describe. The actual exception reported may vary widely according to circumstance.

          Your code should detect the exception and react by clearing the cached entry in the Service Locator and doing a new lookup.

          This should be contained within a loop so that other errors (server still down, etc.) are detected and reported.

          The code might look like :-



          boolean goodLookup = false;
          int retriesToGo = 3;
          Exception fatalException;
          
          home = serviceLocator.fetch( url );
          while ( retriesToGo > 0 && goodLookup == false ) {
           try {
           if ( home == null ) {
           home = serviceLocator.fetch( url );
           }
           remote = home.create( key );
           goodLookup = true;
           }
           catch ( Exception e ) {
           fatalException = e;
           serviceLocator.invalidate( url );
           home = null;
           }
           retriesToGo--;
           } // End of while loop.
          
           // If the lookup fails after three attempts, throw an exception.
           if ( goodLookup == false ) {
           throw fatalException;
           }
          


          obviously with supporting code in the Service Locator.

          James


          • 2. Re: EJB creation fails after server restarts
            gorano Newbie

            What exactly are you caching?

            Initial Context, RemoteHome or/and Remote Object?

            If you give some more background I can give you some hints that works for us.

            /G

            • 3. Re: EJB creation fails after server restarts
              Marc Golinelli Newbie

              gorano,
              We are caching the remote home in our service locator.

              jamesstrachan,
              Thanks for the proposed workaround.

              Besides, all I know is that it workds using WebLogic, I was expecting the same behavior from JBOSS. I dont know if it is allowed in the J2EE specifications.

              Thanks for your help,

              Regards,

              FrereTuck