Hi florian

Florian Ried wrote:
But when I shut down the Jackrabbit-RMI Server and start it again, my servlets or portlets are not able to connect to the resource again and I get an RMI Error.


from ClientRepositoryFactory javadocs
<quote>
The repository references are cached so that only one client instance
(per factory) exists for each remote repository.
</quote>

If you shutdown the rmi server the repository references in the client will become stale, and if you use jndi you won't be able to fix it in your client code.

Anybody can tell me what is the source of the Problem? Is it the ClientRepositoryFactory, does WAS cache the connection?

The source of the problem ;)
ClientRepositoryFactory.getRepository(String url)

Repository repository = (Repository) repositories.get(url);
if (repository == null) {
  RemoteRepository remote = (RemoteRepository) Naming.lookup(url);
  repository = factory.getRepository(remote);
  repositories.put(url, repository);
}
return repository;


Another Question: Is there a disadvantage when accessing the Repository directly from within the servlet (instead of using a JNDI Resource):

ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository r = factory.getRepository("rmi://srv-entw/repository");
Session session = r.login(new SimpleCredentials("userid", "".toCharArray()), null);

With this code, see quote and code above, you'll get a new reference each time, so your client shouldn't be affected by the rmi server restart.

But I like to use jndi, so IMHO the ClientRepositoryFactory should validate the reference to the remote repository and discard the cached references when they become stale, just like a jdbc pool discards stale connections. thoughts?

BR,
edgar


Thank you for your answers.
-Florian




Reply via email to