-
1. Re: EJB creation fails after server restarts
jamesstrachan Jun 27, 2004 6:17 AM (in response to freretuck)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 Jun 28, 2004 4:39 AM (in response to freretuck)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
freretuck Jun 28, 2004 5:34 AM (in response to freretuck)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