Skip to main content

NetPeerGroupFactory can not initial with JXTA_HOME customize.

6 replies [Last post]
thanhlb
Offline
Joined: 2004-04-07
Points: 0

Hi all,

Could you help me solve this problem or explain me what happen with this??
Thank a lot.

************** This is my code for NetworkConfig:***************

File home = new File(".myconfig");
NetworkConfigurator config = new NetworkConfigurator();
config.setHome(home);
if (!config.exists()) {
config.setPeerID(IDFactory.newPeerID(PeerGroupID.defaultNetPeerGroupID));
config.setName(username);
config.setDescription("Created by Aloha");
config.setMode(NetworkConfigurator.EDGE_NODE);
config.setPrincipal(username);
config.setPassword(password);
try {
config.addRdvSeedingURI(new URI(
"http://rdv.jxtahosts.net/cgi-bin/rendezvous.cgi?2"));
config.addRelaySeedingURI(new URI(
"http://rdv.jxtahosts.net/cgi-bin/relays.cgi?2"));
} catch (java.net.URISyntaxException use) {
use.printStackTrace();
}

try {
config.save();
} catch (IOException io) {
io.printStackTrace();
}

********************* Start JxtaNetwork **********************
protected boolean startJXTA() throws Exception {
log.info(System.getProperty("JXTA_HOME"));

PeerGroup worldPeerGroup = new WorldPeerGroupFactory().getInterface();
netPeerGroup = new NetPeerGroupFactory(worldPeerGroup).getInterface();
applicationPeerGroup = netPeerGroup;
PeerGroupID peerGroupBinaryID = MD5ID.createPeerGroupID( netPeerGroup.getPeerGroupID(), "JXTA", "Instant Messenger");
applicationPeerGroup = PeerGroupUtil.createAndJoinPeerGroup( netPeerGroup, "JXTA-Group", peerGroupBinaryID);

...

}

When I run it throw exception below:

Exception in thread "main" net.jxta.exception.JxtaError: Canceled during configuration
at net.jxta.impl.peergroup.ConfigDialog.untilDone(ConfigDialog.java:1597)
at net.jxta.impl.peergroup.DefaultConfigurator.getPlatformConfig(DefaultConfigurator.java:232)
at net.jxta.impl.peergroup.NullConfigurator.getConfigParams(NullConfigurator.java:171)
at net.jxta.peergroup.WorldPeerGroupFactory.(WorldPeerGroupFactory.java:146)
at net.jxta.peergroup.NetPeerGroupFactory.(NetPeerGroupFactory.java:123)
at com.ivy.core.P2PManager.startJXTA(P2PManager.java:66)
at com.ivy.core.JxtaSpaceManager.initJxtaNetwork(JxtaSpaceManager.java:72)
at ApplicationLauncher.startApplication(ApplicationLauncher.java:40)
at MainJxta.(MainJxta.java:7)
at MainJxta.main(MainJxta.java:20)

I intend to config JxtaNetwork by program (it's not force JxtaConfigurator GUI). How can I do that? My code above can create configuration file but this still display JxtaConfigurator GUI.

Thanh.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jimbosi
Offline
Joined: 2007-06-14
Points: 0

I believe you want to be doing something like this:

public void start(){
try {
NetworkConfigurator config = new NetworkConfigurator();
// set whatever options you need

ConfigParams params = config.getPlatformConfig();
URI filestore = new URI("./where/i/want/my/files");
NetPeerGroupFactory factory = new NetPeerGroupFactory(params, filestore);

// this starts the peer group
PeerGroup netPeerGroup = factory.getInterface();

// get the peer group advertisement to customise for our own needs
PeerGroupAdvertisement advert = netPeerGroup.getPeerGroupAdvertisement();
advert.setName("NewGroupName");
advert.setPeerGroupID(IDFactory.newPeerGroupID());

// create our new peer group with the updated advertisement
PeerGroup myPeerGroup = netPeerGroup.newGroup(advert);

} catch (PeerGroupException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

I haven't tested it but it should work.

hope this helps

thanhlb
Offline
Joined: 2004-04-07
Points: 0

Dear Jimbosi,

Thank you for your snippet code. And you I can not setPrincipal("thename") and this raised exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/x509/X509V3CertificateGenerator
at net.jxta.impl.membership.pse.PSEUtils.genCert(PSEUtils.java:289)
at net.jxta.impl.membership.pse.PSEUtils.genCert(PSEUtils.java:245)
at net.jxta.platform.NetworkConfigurator.createPSEAdv(NetworkConfigurator.java:1480)
at net.jxta.platform.NetworkConfigurator.getPlatformConfig(NetworkConfigurator.java:1615)
at net.jxta.platform.NetworkConfigurator.save(NetworkConfigurator.java:1404)
at com.ivy.core.Config.configureAsEdge(Config.java:78)
at com.ivy.core.JxtaSpaceManager.configure(JxtaSpaceManager.java:50)
at ApplicationLauncher.startApplication(ApplicationLauncher.java:44)
at MainJxta.(MainJxta.java:7)
at MainJxta.main(MainJxta.java:20)

Is that reason then my peer have name is "unknown"?
I am using jxta 2.5rc1 version.

Hope to help me.

Thanh Le.

Message was edited by: thanhlb

Message was edited by: thanhlb

buzzheavyyear
Offline
Joined: 2005-06-18
Points: 0

Hi Thanh

If you look at the exception you will see that the error is :

java.lang.NoClassDefFoundError: org/bouncycastle/x509/X509V3CertificateGenerator

You haven't got the bouncycastle jar in your path

Buzz

thanhlb
Offline
Joined: 2004-04-07
Points: 0

Hi Buzz,

I am sure. I included bouncycastle library with this version bcprov-jdk14.jar. Anything else?
Why is my peer display with "unknown" name?

Best day.

Thanh.

buzzheavyyear
Offline
Joined: 2005-06-18
Points: 0

Hi Thanh

Try working through the excellent tutorial and also try this ..

http://www.petrovic.org/blog/2006/11/15/a-turnkey-private-jxta-net-demo

Cheers

hamada
Offline
Joined: 2003-06-12
Points: 0

I would also add, you should avoid creating the world peer group separately (unless you have a reason to), otherwise all you need is to create the NetPeerGroup (which provides access to the WorlPeerGroup see getParent()). Also as buzzheayyear suggests, you should follow the pattern established in the tutorials, as it provides the simplest and least error prone to a successful configuration and instantiation.