---
title: "转：关于P2P的简略总结 "
author: "dukec"
date: "2014-06-30T10:36:17Z"
tags: []
categories: ["开源软件"]
slug: "p2p"
draft: false
lastmod: "2014-06-30T10:36:43Z"
id: 2086633
url: "https://dukec.iteye.com/blog/2086633"
---

前段时间看了点关于P2P技术的资料，现在简单的整理写进自己的博客，对于更深入的学习会在后续的博客中更新总结。

这篇博客的主要内容如下：

1.P2P的定义及特点

2.P2P网络拓扑结构

3.P2P关键技术的初步理解

4.JXTA简介

一、首先了解P2P的定义及特点：

P2P，即Peer-To-Peer的缩写，意思就是伙伴对伙伴、对等、点到点的意思，应用到网络上就是对等网络、点对点传输网络。某些人对P2P给出了数学意义上的严格定义如下：

1.有某网络N，是架构在Internet之上的网络，满足Internet的所有基本特性。

2.在N网络中，存在两种基本的模式，一种行为定义为P，是生产资源（提供资源）的行为，另一种定义为C，是消费资源（接收资源）的行为。

3.组成N网络的所有结点之间是对等关系，且同时具备行为P和行为C。

4.在N网络中，各Peer之间以无中介的、对等的方式进行双向交换，以执行P和C的行为。

5.N网络依赖Peer的存在而存在，Peer可以自由的加入或退出。

6.当有Peer加入或退出时，N网络仍保持组织、结构等特性不变。

根据以上的定义可以从两个方面来解释P2P网络：

1.从网络概念来讲，P2P网络是一种用户之间通过某一个相同的网络应用程序联系起来，彼此之间可以相互访问、共享计算机资源的网络。

2.从应用上来说，P2P网络是一种不通过中央服务器而将一些独立的计算机资源组织起来，通过Internet运行于个人计算机上，以实现共享文件和资源的应用。

从以上对P2P的描述，可知P2P至少有以下三点特点：

1.P2P网络是对等互联的的网络，组成网络的结点之间是对等、伙伴式的关系。

2.P2P网络结点之间资源的传递是从一点到另一点的，每个结点既是资源的提供者同时也是资源的消费者。

3.P2P网络中的资源是依赖于结点的存在而存在的，且资源可以动态的加入或退出。

二、P2P网络拓扑结构：

在现实世界中，P2P不是作为一个独立的个体网络存在的，不需要人为的部署和专门的硬件组网，它是依赖于某个P2P应用系统自发的组成的网络，从Internet的角度来讲，P2P网络是叠加在底层通信网络的基础设施之上的重叠网络，是网络中的网络，是一个分布式的、具有互操作性的自组织系统。P2P网络的拓扑结构对P2P网络的特点、P2P网络的搜索机制、数据传输机制、结点发现以及充分利用并发挥P2P的功能有十分重要的作用。

那么什么是拓扑结构呢？

在计算机科学中，网络拓扑结构是指构成网络成员间特定的物理的、或逻辑的排列方式，直观上看，网络拓扑就是在计算机网络中传输媒体的互连的各种设备的物理布局，特别是计算机分布的位置及电缆如何通过它们。

常用拓扑结构图有星型、总线型、网状、环状、树型如下图所示：

![](http://www.myexception.cn/img/2012/07/01/1748593296.png)![](http://www.myexception.cn/img/2012/07/01/1748593297.png)![](http://www.myexception.cn/img/2012/07/01/1748593298.png)![](http://www.myexception.cn/img/2012/07/01/1748593299.png)![](http://www.myexception.cn/img/2012/07/01/1748593300.png)

对P2P网络而言，一般要构造一个非集中式的拓扑结构，在构造的过程中需要解决网络中的大量结点如何命名、组织以及确定结点的加入或离开方式、出错恢复等问题。  
根据拓扑结构的关系可以将P2P网络拓扑结构分为四种：

1.集中式拓扑  
2.全分布式结构化拓扑  
3.全分布式非结构化拓扑  
4.混合式拓扑

（一）、集中式P2P网络拓扑的原理  
集中式P2P网络类似于一个抽象的“星型网络拓扑”，由一个中央服务以星状的形式与各客户机连接，但这种连接并不是物理上的星状拓扑，而是基于集中式P2P网络拓扑协议而形成的一个虚拟的星状结构。  
在集中式P2P网络中，网络的主体有一个处于中心地位的索引目录服务器和连接到目录服务器的各结点客户机组成，目录服务器用来管理和组织P2P的各客户端结点。  
在网络运行过程中，P2P结点向中央目录服务器注册关于自身的信息（名称、地址、资源和元数据等），但这些注册都分散的存储在各结点中而并非服务器上，查询结点根据目录服务器中的信息的查询来选择与定位其他对等结点并直接建立连接，而不必经过中央目录服务器进行。

（二）、全分布式结构化P2P的原理  
全分布式结构化拓扑的P2P网络主要采用分布式散列表技术来组织网络中的结点。分布式散列表简称DHT，DHT是分布式计算系统中的一类，用来将一个关键值（key）的集合分散到所有的分布式系统中的结点上，并且可以有效地将信息转送到唯一一个拥有查询者提供的关键值的结点。分布式散列表通常是为了拥有极大结点数量的系统，而且系统结点常常会加入或离开而设计的。  
通过DHT技术将广域范围内大量的结点共同形成并维护一个巨大散列表，散列表被分割成不连续的块，每个结点被分配给一个属于自己的散列块，并成为这个散列块的管理者。  
DHT类结构能够自适应结点的动态加入或退出，有着良好的鲁棒性、结点ID分配的均匀性和自组织能力。

（三）、全分布式非结构化的P2P网络原理：  
目前，大多数的P2P应用系统是非结构化拓扑结构，这种结构的覆盖网络一般采用完全随即图的组织方式，结点度数服从幂次法则，从而能够较快的发现目的结点。（幂次法则指的是个体的规模和其名次之间存在着幂次方的反比关系。）  
采用非结构化的P2P系统，对网络动态变化有较好的容错能力，具有较好的可用性，同时支持复杂查询，采用这种结构的典型案例便是Gnutella，它采用了基于完全随机图的洪泛发现和随机转发机制，为了控制搜索消息的传输，通过TTL的减值来实现。  
（四）、混合式P2P网络结构的原理：  
在混合式P2P网络结构中，整个网络中的结点按能力不同区分为普通结点和超级结点两类，超级结点也叫搜索结点，它与其临近的若干普通及诶点之间构成一个小型的、自治的、基于集中式的P2P网络模式。  
这种混合式的P2P拓扑结构在工作过程中，一般会选择一些性能较好的结点作为超级结点，当有结点加入或退出时，系统可以在各个搜索结点之间再次选取性能最优的结点或另外引入一新的性能最优的结点作为索引结点来保存整个网络中可以利用的搜索结点信息，并负责维护整个网络的结构。  
三、下面是对P2P的关键技术的初步了解：  
（一）、P2P网络搜索技术  
P2P根本的思想就在于对等和共享，在P2P系统中，资源分散在各个结点之上，并且结点频繁地加入或退出，使得P2P系统及整个P2P系统的资源都处于不断变化之中，P2P要实现良好、高效、共享机制，就要解决资源的搜索和结点的返现问题。所谓P2P搜索技术，就是一种P2P资源的发现和定位技术。  
P2P搜索技术与其结构是密切联系的，有什么样的P2P网络拓扑基本上也就决定了此网络拓扑下的搜索策略。  
集中式搜索是基于一台或多台中央服务器来进行的。中央服务器负责协调或调度单独注册结点上的资源，中央服务器维持着P2P网络中的结点的源的中央目录，并协调结点间的交互。  
结构化P2P网络的搜索：在结构化的P2P系统中，利用DHT机制来对P2P系统中的文件进行定位，一个文件与一个key值对应，key值一般通过对文件进行哈希得到，系统中的每个结点负责保存一定范围的keys，利用put(key,value)的功能进行结点的信息的发布，利用get(key)功能进行信息查询，通过这种机制可以对P2P网络中的文件进行定位。  
非结构化P2P网络搜索：这种结构的搜索方法分为两类：盲目搜索和启发式搜索。盲目搜索通过在网络中传播查询信息并且把这些信息不断扩散给每个结点，通过这种泛洪方式来搜索想要的资源。启发式搜索在搜索过程中利用一些已有的信息来辅助查找过程。  
混合式P2P网络搜索：这里的混合式P2P搜索技术并不是基于混合式P2P结构的搜索技术，而是运用两种或以上搜索技术进行混合搜索，主要算法：鸡尾酒搜索算法、模拟退火思想的混合搜索算法。

（二）、P2P的体系结构技术  
1.动态变化：P2P系统需要一种动态成员的管理机制，专门进行用户加入、离开以及出错的管理。  
2.平等的参与：对P2P网络中的任意两个结点而言，如何定义这种平等，如何保证它们之间的平等，如何让这种平等在动态的P2P网络中延续下去以及控制这种平等不被破坏。  
3.分散与自治：解决结点在时间和空间上的分散性以及结点在没有中央控制器的前提下，它的运行、控制和管理。  
4.角色的划分：在一个P2P系统中如何区分结点的不同功能，如何划分它们的角色。  
（三）、P2P的内容存储技术  
1.资源的标识：资源的类型包罗万象，如何标识资源的存在  
2.资源的获取：复制和缓存  
（四）、内容传输技术  
P2P通信时需要解决的问题是如何连接其他的终端获得信息、资源和服务，另一个重要问题是如何建立稳定的连接  
（五）、P2P的系统安全技术

在P2P网络中网络安全是特别重要的一项内容，其中主要包括如下几个方面：  
1.密码系统  
2.非公开密钥加密技术  
3.公钥加密技术  
4.数字签名  
5.身份识别和身份认证  
四、JXTA简介

JXTA是一个针对点对点计算的合作项目，它提供一套简单、便利的技术，可以在任何平台、任何地点和任何时间支持P2P计算，是为了构建P2P网络而定制的一组协议。  
JXTA的层次结构  
JXTA平台主要被分为3层，其分层结构如图：

![](http://www.myexception.cn/img/2012/07/01/1748593301.png)

 

上图所示的各个分层中，各层有不同的基本功能：  
核心层（JXTA Core):这一层封装了最根本的东西，包括Peer、对等组、Peer发现、Peer通信、Peer监视和相关的安全原语。  
服务层（JXTA Servers):这一层包括P2P网络不是必需的、但很通用的功能，如查找、共享、索引、代码缓存和内容的机制，以及认证、PKI服务等。  
应用层（JXTA Application):这一层包括应用JXTA服务开发出来的完整的P2P应用程序。  
至于JXTA的一些基本术语，可以在网上搜索《JXTA技术手册》参考。

JXTA协议分类  
JXTA协议由6个为特定的、普及型的P2P网络计算设计的协议构成，分为两类：2个核心协议和4个标准服务协议  
核心协议：对等体端点协议、对等体解析协议  
标准服务协议：对等体发现协议、汇聚协议、对等体信息协议、管道绑定协议

本人对于JXTA的理解就是开发P2P应用程序的类库，但是它是与平台无关的，可以用Java,C++

等语言实现P2P应用程序的开发。  
JXTA - P2P开发平台基本API使用

1\. 安装配置JDK：  
jdk-6u33-windows-i586

2\. 安装配置Eclipse：  
eclipse-java-indigo-SR2-win32

3\. 下载JXTA开发包：  
jxse-src-2.5.zip  
jxse-lib-2.5.zip  
jxse-tutorials-src-2.5.zip  
jxse-doc-2.5.zip

4\. 解压缩得到jar文件：  
将jxse-lib-2.5.zip中解压得到的4个文件：  
bcprov-jdk14.jar  
javax.servlet.jar  
jxta.jar  
org.mortbay.jetty.jar  
复制到任意目录，我放在eclipse安装目录下新建的目录3rd\\jxta中。

5\. 创建Eclipse工程：  
【文件】-&gt;【新建】-&gt;【Java项目】-&gt;【项目名：jxta\_helloworld】-&gt;【下一步】-&gt;【库标签】-&gt;【添加外部JAR】-&gt;【选择解压缩得到的4个jar文件】-&gt;【完成】

6\. 新建package包：  
【jxta\_helloworld工程右键】-&gt;【新建】-&gt;【包】-&gt;【名称：tutorial.helloworld】-&gt;【完成】

7\. 新建java源文件：  
【tutorial.helloworld包右键】-&gt;【新建】-&gt;【类】-&gt;【名称：HelloWorld】-&gt;【完成】

8\. 编辑源代码：  
注意：此源代码来源于jxse-tutorials-src-2.5.zip解压缩得到的src/tutorial/helloworld/HelloWorld.java文件，其他工程也都可用来运行测试。

```
package tutorial.helloworld;

import net.jxta.platform.NetworkManager;
import java.text.MessageFormat;
import java.io.File;

public class HelloWorld {

   
    public static void main(String args[]) {
        NetworkManager manager = null;

        try {
            manager = new NetworkManager(NetworkManager.ConfigMode.ADHOC, "HelloWorld", new File(new File(".cache"), "HelloWorld").toURI());
            System.out.println("Starting JXTA");
            manager.startNetwork();
            System.out.println("JXTA Started");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
        System.out.println("Waiting for a rendezvous connection");
        boolean connected = manager.waitForRendezvousConnection(12000);

        System.out.println(MessageFormat.format("Connected :{0}", connected));
        System.out.println("Stopping JXTA");
        manager.stopNetwork();
    }
}
```

 9. 运行程序：  
【运行】-&gt;【运行方式】-&gt;【Java 应用程序】

10\. 运行结果：  
工程根目录将产生文件夹.cache，控制台输出：  
Starting JXTA  
2012-7-16 17:32:27 net.jxta.platform.NetworkManager configure  
信息: Loading existing configuration. mode = ADHOC  
2012-7-16 17:32:27 net.jxta.platform.NetworkManager startNetwork  
信息: Starting JXTA Network! MODE = ADHOC,  HOME = file:/D:/eclipse/workspace/jxta\_tutorial\_helloworld/.cache/HelloWorld/  
2012-7-16 17:32:27 net.jxta.impl.protocol.RelayConfigAdv &lt;init&gt;  
警告: Unhandled Element: [net.jxta.impl.document.LiteXMLElement@12498b5](mailto:net.jxta.impl.document.LiteXMLElement@12498b5) / isOff = &lt;&lt;null value&gt;&gt;  
2012-7-16 17:32:27 net.jxta.impl.loader.RefJxtaLoader findModuleImplAdvertisement  
警告: No class for urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000C0206  
2012-7-16 17:32:27 net.jxta.peergroup.WorldPeerGroupFactory newWorldPeerGroup  
信息: Making a new World Peer Group instance using : net.jxta.impl.peergroup.Platform  
2012-7-16 17:32:27 net.jxta.impl.cm.SrdiIndex clearSrdi  
信息: Clearing SRDI for null  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Always Access Service (net.jxta.impl.access.always.AlwaysAccessService)  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.IncomingUnicastServer openServerSocket  
信息: Server will accept connections at /0.0.0.0:9701  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the TCP Message Transport (net.jxta.impl.endpoint.tcp.TcpTransport)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Rendezvous Service (net.jxta.impl.rendezvous.RendezVousServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Peerinfo Service (net.jxta.impl.peer.PeerInfoServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Endpoint service (net.jxta.impl.endpoint.EndpointServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : None Membership Service (net.jxta.impl.membership.none.NoneMembershipService)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Resolver service (net.jxta.impl.resolver.ResolverServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Discovery service (net.jxta.impl.discovery.DiscoveryServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the IP Multicast Message Transport (net.jxta.impl.endpoint.mcast.McastTransport)  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport startApp  
警告: Stalled until there is an endpoint service  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp  
警告: Stalled until there is an endpoint service  
2012-7-16 17:32:27 net.jxta.impl.peer.PeerInfoServiceImpl startApp  
警告: Stalled until there is a resolver service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.EndpointServiceImpl startApp  
信息: Endpoint Service started.  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl startApp  
警告: Stalled until there is a rendezvous service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.mcast.McastTransport startApp  
信息: IP Multicast Message Transport started.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport$MessengerSelectorThread run  
信息: MessengerSelectorThread polling started  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport startApp  
信息: TCP Message Transport started.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.IncomingUnicastServer run  
信息: Server is ready to accept connections  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.adhoc.AdhocPeerRdvService &lt;init&gt;  
信息: RendezVous Service is initialized for urn:jxta:jxta-WorldGroup as an ad hoc peer.  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp  
信息: Rendezvous Serivce started  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl beEdge  
信息: Switched to a Edge peer role.  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl startApp  
信息: Discovery service started  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup getInterface  
信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT INCREMENTED TO: 1 by  
net.jxta.peergroup.NetPeerGroupFactory.&lt;init&gt;(NetPeerGroupFactory.java:206)  
2012-7-16 17:32:27 net.jxta.peergroup.NetPeerGroupFactory newNetPeerGroup  
信息: Instantiating net peer group : urn:jxta:jxta-NetGroup  
Parent : urn:jxta:jxta-WorldGroup "World PeerGroup"\[1]  
ID : urn:jxta:jxta-NetGroup  
Name : NetPeerGroup  
impl : null  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup getInterface  
信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT INCREMENTED TO: 2 by  
net.jxta.impl.peergroup.GenericPeerGroup.loadModule(GenericPeerGroup.java:652)  
2012-7-16 17:32:27 net.jxta.impl.cm.SrdiIndex clearSrdi  
信息: Clearing SRDI for NetPeerGroup  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the JXME Proxy Service (net.jxta.impl.proxy.ProxyService)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : PSE Membership Service (net.jxta.impl.membership.pse.PSEMembershipService)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Pipe Service (net.jxta.impl.pipe.PipeServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Router Message Transport (net.jxta.impl.endpoint.router.EndpointRouter)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Always Access Service (net.jxta.impl.access.always.AlwaysAccessService)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Rendezvous Service (net.jxta.impl.rendezvous.RendezVousServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Endpoint service (net.jxta.impl.endpoint.EndpointServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Peerinfo Service (net.jxta.impl.peer.PeerInfoServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Cryptobased-ID Message Transport (net.jxta.impl.endpoint.cbjx.CbJxTransport)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Resolver service (net.jxta.impl.resolver.ResolverServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;  
信息: Adjusting TLS connection idle timeout to 300000 millis.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;  
信息: Adjusting TLS min reconnection idle to 60000 millis.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;  
信息: Adjusting TLS maximum retry queue age to 120000 millis.  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the TLS Message Transport (net.jxta.impl.endpoint.tls.TlsTransport)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded privileged module : Reference Implementation of the Discovery service (net.jxta.impl.discovery.DiscoveryServiceImpl)  
2012-7-16 17:32:27 net.jxta.impl.proxy.ProxyService startApp  
警告: Stalled until there is a endpoint service  
2012-7-16 17:32:27 net.jxta.impl.membership.pse.PSEMembershipService startApp  
信息: PSE Membmership Service started.  
2012-7-16 17:32:27 net.jxta.impl.pipe.PipeServiceImpl startApp  
警告: Stalled until there is an endpoint service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.router.EndpointRouter startApp  
警告: Stalled until there is an endpoint service  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp  
警告: Stalled until there is an endpoint service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.EndpointServiceImpl startApp  
信息: Endpoint Service started.  
2012-7-16 17:32:27 net.jxta.impl.peer.PeerInfoServiceImpl startApp  
警告: Stalled until there is a resolver service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.cbjx.CbJxTransport startApp  
信息: CbJxTransport started  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl startApp  
警告: Stalled until there is a rendezvous service  
2012-7-16 17:32:27 net.jxta.impl.proxy.ProxyService startApp  
警告: Stalled until there is a discovery service  
2012-7-16 17:32:27 net.jxta.impl.pipe.PipeServiceImpl startApp  
警告: Stalled until there is a rendezvous service  
2012-7-16 17:32:27 net.jxta.impl.endpoint.router.EndpointRouter startApp  
警告: Endpoint Router start stalled until rendezvous service available  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.adhoc.AdhocPeerRdvService &lt;init&gt;  
信息: RendezVous Service is initialized for urn:jxta:jxta-NetGroup as an ad hoc peer.  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp  
信息: Rendezvous Serivce started  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl beEdge  
信息: Switched to a Edge peer role.  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl startApp  
信息: Discovery service started  
2012-7-16 17:32:27 net.jxta.impl.proxy.ProxyService startApp  
警告: Stalled until there is a pipe service  
2012-7-16 17:32:27 net.jxta.impl.cm.SrdiIndex &lt;init&gt;  
信息: \[urn:jxta:jxta-NetGroup "NetPeerGroup"\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Initialized pipeResolverSrdi  
2012-7-16 17:32:27 net.jxta.impl.cm.SrdiIndex startGC  
信息: \[urn:jxta:jxta-NetGroup "NetPeerGroup"\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Starting SRDI GC Thread for pipeResolverSrdi  
2012-7-16 17:32:27 net.jxta.impl.cm.SrdiIndex &lt;init&gt;  
信息: \[urn:jxta:jxta-NetGroup "NetPeerGroup"\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Initialized routerSrdi  
2012-7-16 17:32:27 net.jxta.impl.endpoint.router.EndpointRouter startApp  
信息: urn:jxta:jxta-NetGroup "NetPeerGroup"\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2] : Router Message Transport started.  
2012-7-16 17:32:27 net.jxta.impl.proxy.ProxyService startApp  
信息: JXME Proxy Service started.  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup loadModule  
信息: Loaded module : Default Network PeerGroup reference implementation (net.jxta.impl.peergroup.ShadowPeerGroup)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup decRefCount  
信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT DECCREMENTED TO: 1 by  
net.jxta.peergroup.NetPeerGroupFactory.&lt;init&gt;(NetPeerGroupFactory.java:220)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup getInterface  
信息: \[urn:jxta:jxta-NetGroup] GROUP REF COUNT INCREMENTED TO: 1 by  
net.jxta.platform.NetworkManager.startNetwork(NetworkManager.java:412)  
2012-7-16 17:32:27 net.jxta.impl.protocol.RelayConfigAdv &lt;init&gt;  
警告: Unhandled Element: [net.jxta.impl.document.LiteXMLElement@1301ed8](mailto:net.jxta.impl.document.LiteXMLElement@1301ed8) / isOff = &lt;&lt;null value&gt;&gt;  
2012-7-16 17:32:27 net.jxta.platform.NetworkManager startNetwork  
信息: Started JXTA Network!  
2012-7-16 17:32:27 net.jxta.platform.NetworkManager stopNetwork  
信息: Stopping JXTA Network!  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup decRefCount  
信息: \[urn:jxta:jxta-NetGroup] GROUP REF COUNT DECCREMENTED TO: 0 by  
net.jxta.impl.peergroup.RefCountPeerGroupInterface.stopApp(RefCountPeerGroupInterface.java:140)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup decRefCount  
信息: \[urn:jxta:jxta-NetGroup] STOPPING UNREFERENCED GROUP  
2012-7-16 17:32:27 net.jxta.impl.proxy.ProxyService stopApp  
信息: JXME Proxy Service stopped.  
JXTA Started  
Waiting for a rendezvous connection  
Connected :true  
Stopping JXTA  
2012-7-16 17:32:27 net.jxta.impl.cm.Indexer close  
信息: Closing Indexer  
2012-7-16 17:32:27 net.jxta.impl.endpoint.router.EndpointRouter stopApp  
信息: urn:jxta:jxta-NetGroup "NetPeerGroup"\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[1] : Router Message Transport stopped.  
2012-7-16 17:32:27 net.jxta.impl.cm.Indexer close  
信息: Closing Indexer  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl stopApp  
信息: Discovery service stopped.  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl stopApp  
信息: Rendezvous Serivce stopped  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tls.TlsManager close  
信息: Shutting down all connections  
2012-7-16 17:32:27 net.jxta.impl.endpoint.cbjx.CbJxTransport stopApp  
信息: CbJxTransport stopped  
2012-7-16 17:32:27 net.jxta.impl.endpoint.EndpointServiceImpl stopApp  
信息: Endpoint Service stopped.  
2012-7-16 17:32:27 net.jxta.impl.membership.pse.PSEMembershipService stopApp  
信息: PSE Membmership Service stopped.  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup decRefCount  
信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT DECCREMENTED TO: 0 by  
net.jxta.impl.peergroup.GenericPeerGroup.stopApp(GenericPeerGroup.java:1245)  
2012-7-16 17:32:27 net.jxta.impl.peergroup.GenericPeerGroup decRefCount  
信息: \[urn:jxta:jxta-WorldGroup] STOPPING UNREFERENCED GROUP  
2012-7-16 17:32:27 net.jxta.impl.discovery.DiscoveryServiceImpl stopApp  
信息: Discovery service stopped.  
2012-7-16 17:32:27 net.jxta.impl.rendezvous.RendezVousServiceImpl stopApp  
信息: Rendezvous Serivce stopped  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.IncomingUnicastServer run  
信息: Server has been shut down.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: Total bytes sent : 0  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: Total Messages sent : 0  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: Total bytes received : 0  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: Total Messages received : 0  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: Total connections accepted : 0  
2012-7-16 17:32:27 net.jxta.impl.endpoint.tcp.TcpTransport stopApp  
信息: TCP Message Transport shut down.  
2012-7-16 17:32:27 net.jxta.impl.endpoint.EndpointServiceImpl stopApp  
信息: Endpoint Service stopped.  
2012-7-16 17:32:27 net.jxta.impl.cm.Indexer close  
信息: Closing Indexer  
2012-7-16 17:32:27 net.jxta.impl.cm.Indexer close  
信息: Closing Indexer  
2012-7-16 17:32:27 net.jxta.platform.NetworkManager stopNetwork  
信息: Stopped JXTA Network!

 

11\. 另一个测试程序：

 

```
package p2p.jxta.helloworld;

import net.jxta.exception.PeerGroupException;
import net.jxta.peergroup.PeerGroup;
import net.jxta.peergroup.PeerGroupFactory;

public class HelloWorld_JXTA {

 public static void main(String args[]) {
   System.out.println("Start JXTA....");
   HelloWorld_JXTA myapp = new HelloWorld_JXTA();
   myapp.startJXTA();
   System.exit(0);
 }
 
 public void startJXTA(){
   PeerGroup pg = null;
   try {
     pg = PeerGroupFactory.newNetPeerGroup();
   }catch (PeerGroupException e) {
      System.out.println("Fatal error:group creation failure");
      e.printStackTrace();
      System.exit(1);
   }
   System.out.println("Hello JXTA!:)");
   System.out.println("Group name = "+pg.getPeerGroupName());
   System.out.println("Group ID = "+pg.getPeerGroupID().toString());
   System.out.println("Peer name = "+pg.getPeerName());
   System.out.println("Peer ID = "+pg.getPeerID().toString());
   System.out.println("Peer BaseClass = "+pg.refTcpProtoSpecID.getBaseClass());
 }

}
```

 12. 测试运行：  
任意输入用户名和长度大于8位的密码。

 

 

![JXTA <wbr>- <wbr>P2P开发平台基本API使用](http://s13.sinaimg.cn/middle/76fbd24d4c51118e71b7c&690 "JXTA <wbr>- <wbr>P2P开发平台基本API使用")

Relay seeding URIs：任意填写IP地址，并点击【+】添加。

![JXTA <wbr>- <wbr>P2P开发平台基本API使用](http://s8.sinaimg.cn/middle/76fbd24d4c4ef21fbfb07&690 "JXTA <wbr>- <wbr>P2P开发平台基本API使用")

控制台输出：

**Start JXTA....**

2012-7-16 17:33:43 net.jxta.impl.peergroup.NullConfigurator load

警告: Platform Config not found : file:/D:/eclipse/workspace/jxta\_helloworld/.jxta/PlatformConfig

2012-7-16 17:34:03 net.jxta.impl.membership.pse.PSEUtils &lt;init&gt;

信息: Loaded Security Providers into system class loader

2012-7-16 17:34:04 net.jxta.impl.loader.RefJxtaLoader findModuleImplAdvertisement

警告: No class for urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000C0206

2012-7-16 17:34:04 net.jxta.peergroup.WorldPeerGroupFactory newWorldPeerGroup

信息: Making a new World Peer Group instance using : net.jxta.impl.peergroup.Platform

2012-7-16 17:34:04 net.jxta.impl.cm.SrdiIndex clearSrdi

信息: Clearing SRDI for null

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Always Access Service (net.jxta.impl.access.always.AlwaysAccessService)

2012-7-16 17:34:04 net.jxta.impl.endpoint.tcp.IncomingUnicastServer openServerSocket

信息: Server will accept connections at /0.0.0.0:14419

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the TCP Message Transport (net.jxta.impl.endpoint.tcp.TcpTransport)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Rendezvous Service (net.jxta.impl.rendezvous.RendezVousServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Peerinfo Service (net.jxta.impl.peer.PeerInfoServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Endpoint service (net.jxta.impl.endpoint.EndpointServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the HTTP Message Transport (net.jxta.impl.endpoint.servlethttp.ServletHttpTransport)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : None Membership Service (net.jxta.impl.membership.none.NoneMembershipService)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Resolver service (net.jxta.impl.resolver.ResolverServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Discovery service (net.jxta.impl.discovery.DiscoveryServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the IP Multicast Message Transport (net.jxta.impl.endpoint.mcast.McastTransport)

2012-7-16 17:34:04 net.jxta.impl.endpoint.tcp.TcpTransport startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.peer.PeerInfoServiceImpl startApp

警告: Stalled until there is a resolver service

2012-7-16 17:34:04 net.jxta.impl.endpoint.EndpointServiceImpl startApp

信息: Endpoint Service started.

2012-7-16 17:34:04 net.jxta.impl.endpoint.servlethttp.HttpMessageSender start

信息: HTTP Client Transport started.

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl startApp

警告: Stalled until there is a rendezvous service

2012-7-16 17:34:04 net.jxta.impl.endpoint.mcast.McastTransport startApp

信息: IP Multicast Message Transport started.

2012-7-16 17:34:04 net.jxta.impl.endpoint.tcp.TcpTransport$MessengerSelectorThread run

信息: MessengerSelectorThread polling started

2012-7-16 17:34:04 net.jxta.impl.endpoint.tcp.TcpTransport startApp

信息: TCP Message Transport started.

2012-7-16 17:34:04 net.jxta.impl.endpoint.tcp.IncomingUnicastServer run

信息: Server is ready to accept connections

2012-7-16 17:34:04 net.jxta.impl.rendezvous.adhoc.AdhocPeerRdvService &lt;init&gt;

信息: RendezVous Service is initialized for urn:jxta:jxta-WorldGroup as an ad hoc peer. 

2012-7-16 17:34:04 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp

信息: Rendezvous Serivce started

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl beEdge

信息: Switched to a Edge peer role.

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl startApp

信息: Discovery service started

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup getInterface

信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT INCREMENTED TO: 1 by

net.jxta.peergroup.PeerGroupFactory.newPlatform(PeerGroupFactory.java:425)

2012-7-16 17:34:04 net.jxta.peergroup.NetPeerGroupFactory newNetPeerGroup

信息: Instantiating net peer group : urn:jxta:jxta-NetGroup

Parent : urn:jxta:jxta-WorldGroup "World PeerGroup"\[1]

ID : urn:jxta:jxta-NetGroup

Name : NetPeerGroup

impl : null

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup getInterface

信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT INCREMENTED TO: 2 by

net.jxta.impl.peergroup.GenericPeerGroup.loadModule(GenericPeerGroup.java:652)

2012-7-16 17:34:04 net.jxta.impl.cm.SrdiIndex clearSrdi

信息: Clearing SRDI for null

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Relay Message Transport (net.jxta.impl.endpoint.relay.RelayTransport)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : PSE Membership Service (net.jxta.impl.membership.pse.PSEMembershipService)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Pipe Service (net.jxta.impl.pipe.PipeServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Router Message Transport (net.jxta.impl.endpoint.router.EndpointRouter)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Always Access Service (net.jxta.impl.access.always.AlwaysAccessService)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Rendezvous Service (net.jxta.impl.rendezvous.RendezVousServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Endpoint service (net.jxta.impl.endpoint.EndpointServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Peerinfo Service (net.jxta.impl.peer.PeerInfoServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Cryptobased-ID Message Transport (net.jxta.impl.endpoint.cbjx.CbJxTransport)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Resolver service (net.jxta.impl.resolver.ResolverServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;

信息: Adjusting TLS connection idle timeout to 300000 millis.

2012-7-16 17:34:04 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;

信息: Adjusting TLS min reconnection idle to 60000 millis.

2012-7-16 17:34:04 net.jxta.impl.endpoint.tls.TlsTransport &lt;init&gt;

信息: Adjusting TLS maximum retry queue age to 120000 millis.

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the TLS Message Transport (net.jxta.impl.endpoint.tls.TlsTransport)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded privileged module : Reference Implementation of the Discovery service (net.jxta.impl.discovery.DiscoveryServiceImpl)

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayTransport startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.membership.pse.PSEMembershipService startApp

信息: PSE Membmership Service started.

2012-7-16 17:34:04 net.jxta.impl.pipe.PipeServiceImpl startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.endpoint.router.EndpointRouter startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp

警告: Stalled until there is an endpoint service

2012-7-16 17:34:04 net.jxta.impl.endpoint.EndpointServiceImpl startApp

信息: Endpoint Service started.

2012-7-16 17:34:04 net.jxta.impl.peer.PeerInfoServiceImpl startApp

警告: Stalled until there is a resolver service

2012-7-16 17:34:04 net.jxta.impl.endpoint.cbjx.CbJxTransport startApp

信息: CbJxTransport started

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl startApp

警告: Stalled until there is a rendezvous service

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayTransport startApp

警告: Stalled until there is a discovery service

2012-7-16 17:34:04 net.jxta.impl.pipe.PipeServiceImpl startApp

警告: Stalled until there is a rendezvous service

2012-7-16 17:34:04 net.jxta.impl.endpoint.router.EndpointRouter startApp

警告: Endpoint Router start stalled until rendezvous service available

2012-7-16 17:34:04 net.jxta.impl.rendezvous.edge.EdgePeerRdvService &lt;init&gt;

信息: RendezVous Service is initialized for urn:jxta:jxta-NetGroup as an Edge peer.

2012-7-16 17:34:04 net.jxta.impl.rendezvous.RendezVousServiceImpl startApp

信息: Rendezvous Serivce started

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl beEdge

信息: Switched to a Edge peer role.

2012-7-16 17:34:04 net.jxta.impl.discovery.DiscoveryServiceImpl startApp

信息: Discovery service started

2012-7-16 17:34:04 net.jxta.impl.rendezvous.edge.EdgePeerRdvService$MonitorTask run

警告: Rendezvous connection stalled until router is started!

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayTransport startApp

警告: Stalled until there is a pipe service

2012-7-16 17:34:04 net.jxta.impl.cm.SrdiIndex &lt;init&gt;

信息: \[urn:jxta:jxta-NetGroup\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Initialized pipeResolverSrdi

2012-7-16 17:34:04 net.jxta.impl.cm.SrdiIndex startGC

信息: \[urn:jxta:jxta-NetGroup\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Starting SRDI GC Thread for pipeResolverSrdi

2012-7-16 17:34:04 net.jxta.impl.cm.SrdiIndex &lt;init&gt;

信息: \[urn:jxta:jxta-NetGroup\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2]] : Initialized routerSrdi

2012-7-16 17:34:04 net.jxta.impl.endpoint.router.EndpointRouter startApp

信息: urn:jxta:jxta-NetGroup\[0] / urn:jxta:jxta-WorldGroup "World PeerGroup"\[2] : Router Message Transport started.

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayClient startClient

信息: Started client : relay://uuid-59616261646162614A7874615032503390C03A49115B41F68165C478286CEE2303

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayClient run

信息: Start relay client thread

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayTransport startApp

信息: Relay Message Transport started

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayClient run

严重: Uncaught Throwable in thread :Relay Client Worker Thread for relay://uuid-59616261646162614A7874615032503390C03A49115B41F68165C478286CEE2303

java.lang.IllegalArgumentException: URI is not absolute

at java.net.URI.toURL(Unknown Source)

at net.jxta.impl.util.URISeedingManager.loadSeeds(URISeedingManager.java:450)

at net.jxta.impl.util.URISeedingManager.refreshActiveSeeds(URISeedingManager.java:360)

at net.jxta.impl.util.URISeedingManager.getActiveSeedRoutes(URISeedingManager.java:283)

at net.jxta.impl.endpoint.relay.RelayClient.run(RelayClient.java:344)

at java.lang.Thread.run(Unknown Source)

2012-7-16 17:34:04 net.jxta.impl.endpoint.relay.RelayClient run

信息: stop client thread

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup loadModule

信息: Loaded module : Default Network PeerGroup reference implementation (net.jxta.impl.peergroup.ShadowPeerGroup)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup getInterface

信息: \[urn:jxta:jxta-NetGroup] GROUP REF COUNT INCREMENTED TO: 1 by

net.jxta.peergroup.PeerGroupFactory.newNetPeerGroup(PeerGroupFactory.java:501)

2012-7-16 17:34:04 net.jxta.impl.peergroup.GenericPeerGroup decRefCount

信息: \[urn:jxta:jxta-WorldGroup] GROUP REF COUNT DECCREMENTED TO: 1 by

net.jxta.peergroup.PeerGroupFactory.newNetPeerGroup(PeerGroupFactory.java:552)

**Hello JXTA!:)**

**Group name = NetPeerGroup**

**Group ID = urn:jxta:jxta-NetGroup**

**Peer name = xsj**

**Peer ID = urn:jxta:uuid-59616261646162614A7874615032503390C03A49115B41F68165C478286CEE2303**

**Peer BaseClass = urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000905**

 

**13. 注意事项：**

（1）对于编码中用到Unicode中文，可能会报错，需要修改文本文件编码：

【窗口】-&gt;【首选项】-&gt;【常规】-&gt;【工作空间】-&gt;【文本文件编码】-&gt;【点选：其他】-&gt;【下拉选择：UTF-8】-&gt;【应用】-&gt;【确定】

 

（2）JXTA2.5，在创建一个类似HelloWorld程序的时候，可能出现一个异常，这个异常信息大致是：

警告: Failed to find class for urn:jxta:uuid-...

java.lang.ClassNotFoundException:...

出现这个异常是由于JXTA2.5的jar包引起的，在jxta.jar包的内部有一个bug，需要修正一下，具体解决方法是：

jxta.jar包里面的\\META-INF\\services\\net.jxta.platform.Module后面加上一句：

**urn:jxta:uuid-deadbeefdeafbabafeedbabe0000000C0206 net.jxta.impl.shell.ShellApp Reference Implementation of Shell**

 

（3）第二个测试程序运行后将在工程根目录产生.settings文件夹，如果不删除则下次运行时将不会产生上述两个界面，删除后可以看到。

 

**14. 参考资料：**

\[1] http://download.java.net/jxta/

\[2] http://java.net/projects/jxta