Skip to main content

Problem when attempting to load .jar modules

1 reply [Last post]
Anonymous

Hi, i'm working with jxse2.6 to develop a program for my university thesis.
Substantially, my application has to download modules in .jar format from given addresses, store them in a cache directory and finally load the "main" module in a given PeerGroup, son of the NetPeerGroup.

for do it, my edge application calls their rendezvous and it respond with the moduleImplAdv of all the modules needed, generated with this method ("just for run" dummy version):

<br />
	private static ModuleImplAdvertisement getModuleImplAdvertisement()<br />
	{</p>
<p>		String moduleClassIDString =<br />
			"urn:jxta:uuid-1299BA4C40974294862BB3F029E076A505";</p>
<p>		ModuleClassID modClassID = null;<br />
		ModuleSpecID modSpecID = null;<br />
			try {<br />
				modClassID = ModuleClassID.create(new URI(moduleClassIDString));<br />
				modSpecID = IDFactory.newModuleSpecID(modClassID);<br />
			} catch (Exception e) {}</p>
<p>		String moduleName = "Claustrophobia ZRV Service";<br />
		String moduleNameSpace = "Claustrophobia_ZRV_service";<br />
		String moduleCreator = "The dark Lord of Peervana";<br />
		String moduleVersion = "0.1";<br />
		String moduleDescription = "Claustrophobia ZoneRV Base Service Module";<br />
		String moduleURI = "http://www.idontwanttospammywebsite.com/peervana/claustrophobiaNet.jar";</p>
<p>		ModuleImplAdvertisement moduleImplAdv = (ModuleImplAdvertisement)<br />
			AdvertisementFactory.newAdvertisement(ModuleImplAdvertisement.getAdvertisementType());</p>
<p>                // TODO: Retrieving .jar parameters from db<br />
		moduleImplAdv.setDescription(moduleDescription);<br />
		moduleImplAdv.setModuleSpecID(modSpecID);<br />
		moduleImplAdv.setProvider(moduleName);<br />
		moduleImplAdv.setCode("net.Launch");</p>
<p>		// Setting compatibility<br />
		moduleImplAdv.setCompat(StdPeerGroup.STD_COMPAT);</p>
<p>		// TODO: Retrieving location of .jar File from db<br />
		moduleImplAdv.setUri(moduleURI);<br />
		return moduleImplAdv;<br />
	}<br />

the rendezvous sends the moduleImplAdv list in a message to the Edge, and when the Edge has received the message it retrieves the advertisements, downloads the files, locates the main jar and calls this method for load the main module:

<br />
	public void loadZoneModules(PeerGroup zonePeerGroup,<br />
								File zoneCache,<br />
								Advertisement moduleAdvertisement)<br />
	{<br />
		try<br />
		{<br />
			ModuleImplAdvertisement mIAdv = (ModuleImplAdvertisement)moduleAdvertisement;<br />
			//SRV_Service_Module<br />
			ModuleClassID modClassID = mIAdv.getModuleSpecID().getBaseClass();<br />
			//System.out.println("            modClassID\n"+modClassID.toString());</p>
<p>			/*<br />
			 * substitution of the remote uri with the local absolute path<br />
			 */<br />
			String fileName = mIAdv.getUri();<br />
			fileName = fileName.substring(<br />
					fileName.lastIndexOf(System.getProperty("file.separator")));<br />
			mIAdv.setUri(zoneCache.getAbsolutePath()+fileName);</p>
<p>			/*<br />
			 * load the module<br />
			 */<br />
			Module zoneModule = zonePeerGroup.loadModule(modClassID, mIAdv);<br />
			zoneModule.init(zonePeerGroup, modClassID, mIAdv);<br />
			zoneModule.startApp(new String[0]);</p>
<p>		} catch (PeerGroupException e) { e.printStackTrace();<br />
		} catch (ProtocolNotSupportedException e) { e.printStackTrace(); }<br />
	}<br />

When the edge run this, throws the following error:

GRAVE: Line 218 net.jxta.impl.pipe.InputPipeImpl.processIncomingMessage()
Uncaught Throwable in listener for : urn:jxta:uuid-636C61757374426FB068AF6269615F74AB76254CB1E046BCBC26B40FF216FD2E04(net.jxta.util.JxtaBiDiPipe)
java.lang.ClassFormatError: Class 'net.Launch' could not be loaded from : /home/decimo/java/peervana/./Peervana Client_cache/zones/Peervana Zone RendezVous of Claustrophobia/claustrophobiaNet.jar
Line 417 net.jxta.impl.loader.RefJxtaLoader.defineClass()
Line 729 net.jxta.impl.peergroup.GenericPeerGroup.loadModule()
Line 684 net.jxta.impl.peergroup.GenericPeerGroup.loadModule()
Line 187 modules.functions.ClientFunctions.loadZoneModules()
Line 286 com.Client.pipeMsgEvent()
(..........)

I have verified the following:
-Class 'net.Launch' is the mainclass entrypoint of the claustrophobiaNet.jar
-net.Launch has the correct package, implement Service and has a main() method.
-the file claustrophobiaNet.jar is correctly stored and the path is correct.

I think it's a problem of compatibility or a wrong method to reference the class into the jar, however i don't have founded anything in the net or in "Practical JXTA" (thanks Jérome, very useful book) it can help me.

thanks for the help and sorry for my english...

Message was edited by: decimo

Message was edited by: decimo

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
adamman71
Offline
Joined: 2007-01-31
Points: 0

Sorry for the late reply.
In the module spec advertisement, you should use the same values as those defined in the astrology service code example ( i.e, "1.0").
For the module implementation advertisement, you may want to take a look at the CompatibilityUtils class code.
Why no info? The story behind this is long. The summary is: JXTA is trying to solve a problem that OSGI has already solved in a better way. There is no simple solution to this version issue in JXTA. Hence, this is why we have not fixed it. It looks like we are not going to fix it too. If you need to load modules on peers, consider investigating your time in OSGi rather than JXTA.
My bet is that sooner or later, we'll toss loading services on peers, because JXTA is bad at it and it does not seem like the community is interested in re-inventing the wheel...