Skip to main content

[JXSE 2.6] and Equinox, part deux

9 replies [Last post]
keesp
Offline
Joined: 2007-05-22
Points: 0

Hi,

In my slow but steady quest to create a JXSE 2.6 plugin for equinox, I have encountered another problem, which I could use some help with.

When I start up the network manager, I get the error message depicted below. I have been following the error, and I know where it originates from, but I'm not quite sure how to resolve it correctly.

I have the feeling that the key that is requested is stored in the config.properties file which is loaded when starting the IDFactory, but I can't seem to figure out where the properties are actually registered in the ClassFactory.

I would be helped if someone could point out the correct way to approach this problem.

Thanks

Kees

java.util.NoSuchElementException: key 'uuid' not registered.
at net.jxta.util.ClassFactory.getInstantiator(ClassFactory.java:357)
at net.jxta.id.IDFactory.newPeerID(IDFactory.java:1231)
at net.jxta.platform.NetworkManager.(NetworkManager.java:190)
at net.jxta.platform.NetworkManager.(NetworkManager.java:172)
at org.condast.jxse.Activator.start(Activator.java:22)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:783)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:774)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:755)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:352)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:370)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1068)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:557)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:464)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:248)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:445)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:227)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:337)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
keesp
Offline
Joined: 2007-05-22
Points: 0

I would like to give one small issue for your consideration for the coming release. It is a minor problem, and also a minor solution in the ClassFactory (see code below):

If the providerlist is empty, it would seem to me that an exception should be thrown that stops the application, as JXTA cannot start properly.

Do you think it is worth implementing this?

Kind regards,

Kees

protected boolean registerProviders(String interfaceName) {
ClassLoader loader = getClass().getClassLoader();
boolean registeredSomething = false;
try {
Enumeration providerLists = loader.getResources("META-INF/services/" + interfaceName);
.....
while (providerLists.hasMoreElements()) {
badURI);
}
}
} catch (IOException ex) {
....
}
return registeredSomething;
}

adamman71
Offline
Joined: 2007-01-31
Points: 0

+1 for me, but since it is minor, I'd rather keep it for Cassoulet.

keesp
Offline
Joined: 2007-05-22
Points: 0

OK,

Another one ;)

In ClassFactory:

The method depicted below is, as far as I can see, not being used. I would suggest to deprecate it, because it will make porting to equinox quite complicated:

Cheers

Kees

protected boolean registerFromResources(String resourceName, String propertyName) throws MissingResourceException {
return registerFromString(fromProps);
....
}

adamman71
Offline
Joined: 2007-01-31
Points: 0

I would check this with Mike first for confirmation, but otherwise...

keesp
Offline
Joined: 2007-05-22
Points: 0

Yes, I understand. That's why I'm posting them as suggestions, so that the experts can overrule them if necessary.

The problem was indeed as Mike suggested. I have put the services in Equinox META-INF subdirectory and it works like a charm.

Thanks for the help

Kees

bondolo
Offline
Joined: 2003-06-11
Points: 0

The registrations are part of the META-INF/services bootstrapping process. Most likely the services files aren't in the class path. If you look in a normal jxta.jar you'll see a number of file entries :

0 06-18-09 11:25 META-INF/services/
226 06-18-09 11:25 META-INF/services/net.jxta.content.ContentProviderSPI
1025 06-18-09 11:25 META-INF/services/net.jxta.document.Advertisement
198 06-18-09 11:25 META-INF/services/net.jxta.document.StructuredDocument
163 06-18-09 11:25 META-INF/services/net.jxta.endpoint.WireFormatMessage
127 06-18-09 11:25 META-INF/services/net.jxta.id.ID
3623 06-18-09 11:25 META-INF/services/net.jxta.platform.Module

These files are loaded by the ClassFactory on behalf of they name to identify to create instances of the respective interface.

keesp
Offline
Joined: 2007-05-22
Points: 0

Ok,

I will try to trace this process tomorrow and see if I can fix this. I'll keep you posted!

Thanks for the feedback!

Kees

adamman71
Offline
Joined: 2007-01-31
Points: 0

Do you have a code example to replicate the issue?

keesp
Offline
Joined: 2007-05-22
Points: 0

Yep...it's very simple: start the network manager as is done in the 2.5 tutorial (pg. 58).In my case I am doing this from the Activator of an equinox plugin:

try {
manager = new NetworkManager(NetworkManager.ConfigMode.EDGE, "HelloWorld");
...
} catch (Exception e) {
e.printStackTrace();
}
...

The manager first calls the iDFactory (see a previous post) in order to load the config.properties file and then prepares something prior to calling the ClassFactory. In the classfactory a map is filled, with one key that apparently should be the 'uuid'. I can't seem to figure out where this key-value pair is added to the map. I had thought it would have been filled in somewhere from the config. properties file, but I may be wrong here...

To complicate matters by the way, I have implemented the JXSE 2.6 code as an equinox plugin, and asm calling the methods from another plugin that will be the actual application. So it undoubtedly has to do with this. It is quite possible that something else is going worng that is not showing an error message, for instance a resource bundle that isn't loaded, or something similar.

Message was edited by: keesp