The Artima Developer Community
Sponsored Link

Jini Forum
LookupCache always returns null

1 reply on 1 page. Most recent reply: Dec 9, 2002 5:56 AM by J

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
J

Posts: 2
Nickname: jill
Registered: Dec, 2002

LookupCache always returns null Posted: Dec 6, 2002 7:56 AM
Reply to this message Reply
Advertisement
I've been gradually working my way through Core Jini (2nd ed.), and I've hit a problem with the lookup cache, as in it always returns null. I have been able to locate the service item successfully using the SericeDiscoveryManager lookup method, but when I create a lookup cache and then later search this for the same service item, it's always returned null. Why does the cache not work?

Below is a basic description of what I'm doing:

---------------------------------------------------------------------------
- --------------------------------------------------------------------------
Class es: Service, ServiceProvider, Client

Ports: HttpServer - port 8080
Rmid - default port 1098(?)
Service HttpServer - port 8086

VM Params: -Drmi.server.codebase=http:\\hostname:8086
-Djava.security.policy={position of policy file, which grants
all Permissions}
---------------------------------------------------------------------------
-- -------------------------------------------------------------------------

The service is registered with reggie in ServiceProvider using JoinManager:

LookupDiscoveryManager discoveryManager
= new LookupDiscoveryManager(new String[] { //group name },
null, null);
// the parameter 'this' is the ServiceIDListener, which is implemented
// by ServiceProvider.
JoinManager joinManager
= new JoinManager(this.service, null, this, discoveryManager, null);

I know this works because I have a log which prints out the service Id,
thus proving that the service has been successfully registered. I've narrowed
down the problem to the lookup cache...

- First initialise the lookup cache:

LookupDiscoveryManager discoveryManager
= new LookupDiscoveryManager(new String[] { //group name },
null, null);
serviceDiscoveryManager = new ServiceDiscoveryManager(discoveryManager, null);
template = new ServiceTemplate(null,new Class[]{ Service.class }, null);

// CachingListener is an inner class which implements the
// ServiceDiscoveryListener interface.
lookupCache = serviceDiscoveryManager.createLookupCache(template,
null,
new CachingListener());


- Then look for a service:

while(true){
try {
// give it 20 seconds so as to rule out the possibility of
// not having enough time.
Thread.sleep(20000);
ServiceItem serviceItem = lookupCache.lookup(null);
logger.info("Service item found in cache = " + serviceItem);
}
catch (InterruptedException e) {
}
}


The problem is that when a lookup on a cache occurs, the ServiceItem returned
is always null. However if the lookup is called directly on the
ServiceDiscoveryManager, the ServiceItem is returns as the service that was
registered through the JoinManager.

while(true){
try {
// give it 20 seconds so as to rule out the possibility of
// not having enough time.
ServiceItem service = serviceDiscoveryManager.lookup(template, null);
logger.info("Service item found without cache = " + service);
}
catch (InterruptedException e) {
}
}


Can anyone see why the use of LookupCache, as above, fails to locate a service that I know is registered?


J

Posts: 2
Nickname: jill
Registered: Dec, 2002

Re: LookupCache always returns null Posted: Dec 9, 2002 5:56 AM
Reply to this message Reply
ok, problem solved....

jini 1.2.1 provides a jar -> sdm-dl.jar, which needs to be included in the application's codebase:


-Djava.rmi.server.codebase="http://myHost:8082/myApp-dl.jar http://myHost:8080/sdm-dl.jar"

The example above assumes that you have two HTTP servers, one listening on port 8082, serving your application-specific JAR files, and one listening on port 8080, serving the JAR files provided with the Jini Technology Starter Kit.

I found this solution at:
http://www.eecs.harvard.edu/~jonathan/jini/doc/release-notes/jxp/servicediscovery.html)

Flat View: This topic has 1 reply on 1 page
Topic: Jini JXTA and non-Java clients Previous Topic   Next Topic Topic: My client can't show the service added

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use