您的位置:首页 > 编程语言 > Java开发

Openfire源代码在Eclipse3.5.2中的部署、编译、运行、配置安装之一

2013-11-20 10:23 417 查看
一、准备工作1、到官方网站下载:Openfire(版本)、Spark(版本2.6.3)、Smack(版本3.1.0),其中Spark只能使用SVN下载,源码的文件夹分别对应Openfire、Spark和Smack。2、网址:http://www.igniterealtime.org/downloads/source.jsp,界面显示如下图:


二、创建Java Project项目——Openfire1、使用Eclipse-2、选择File——New——Project——Java Project。输入项目工程名Openfire,Contents中选择 "Create project from existiing source",然后把Openfire文件所在的文件夹加进去。如下图所示:


3、点击“Finish”,完成。4、在Eclipse的Package Explorer中的显示如下图所示:


源码导入后如果发现源码中报错,则删除错误所在的plugin包即可(一般是plugin包报错)

三、生成、编译、运行Openfire1、生成Openfire
1.1点击Window——Show View——Ant;

1.2右击Ant面板,选择Add Buildfiles;

1.3展开Openfire——build文件夹,选择build.xml,点击"OK";

1.4在Ant面板,展开Openfire XMPP Server,双击"openfire[default]";

1.5等一段时间,会提示"Build Successful";

1.6生成target、work文件夹,重新编译时,要手工删除此文件夹。

注意:如果没有显示“Build Successful”,则再次双击“openfire[default]”.

如下图所示:



2、配置Openfire运行环境
2.1点击Run——Run Configurations

2.2 点击“Main”

Name填写:Openfire

Project:Openfire(选择Openfire工程)

Main class:org.jivesoftware.openfire.starter.ServerStarter(启动类)

勾选Stop in main

如下图:



2.3 Arguments页面,在VM arguments中加下内容,如下图: -DopenfireHome="${workspace_loc:Openfire}/target/openfire"



2.4点击Classpath标签页

选择User Entries ,使得Advanced..按钮变的可用.点击Advanced按钮.在弹出来的Advanced Options窗口,选择Add Folders,再点OK, 在Folder Selection窗口选择Openfire/resources/i18n文件夹,同样的方式选择Openfire/src/resources文件夹,点击OK。



2.5选择Common标签页,勾选Debug,Run前面的框。点击Apply,再点击Close。

3、运行Openfire
3.1如下图



3.2 如下图,点击“run”运行Openfire



运行后,在控制台显示如下:

Openfire [Aug 17, 2010 8:59:32 PM]

Admin console listening at http://127.0.0.1:9090
4、运行Openfire出现的错误,及解决方法
4.1 错误信息




4.2 解决方法

拷贝src\i18n\openfire_i18n_en.properties和src\resources\jar\admin-sidebar.xml到openfire\bin目录下。其中openfire\bin目录在Eclipse中无法看到,到源目录下操做。



错误信息2:

[java]
view plaincopyprint?

log4j:WARN No appenders could be found for logger (org.jivesoftware.util.Log).
log4j:WARN Please initialize the log4j system properly.
Could not locate home
java.io.FileNotFoundException
at org.jivesoftware.openfire.XMPPServer.locateOpenfire(XMPPServer.java:874)
at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:347)
at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:468)
at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:212)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:113)
at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:58)
启动服务器时出错。请检查日志文件以获取更多信息。

log4j:WARN No appenders could be found for logger (org.jivesoftware.util.Log).
log4j:WARN Please initialize the log4j system properly.
Could not locate home
java.io.FileNotFoundException
	at org.jivesoftware.openfire.XMPPServer.locateOpenfire(XMPPServer.java:874)
	at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:347)
	at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:468)
	at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:212)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:113)
	at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:58)
启动服务器时出错。请检查日志文件以获取更多信息。


解决办法:

这种情况是由于源码中配置的路径错误引起的,请打开文件org.jivesoftware.openfire.XMPPServer
我们来看这一行

[java]
view plaincopyprint?

// If we still don't have home, let's assume this is standalone
// and just look for home in a standard sub-dir location and verify
// by looking for the config file
if (openfireHome == null) {
try {
openfireHome = verifyHome("..", jiveConfigName).getCanonicalFile();
}
catch (FileNotFoundException fe) {
// Ignore.
}
catch (IOException ie) {
// Ignore.
}
}

// If we still don't have home, let's assume this is standalone
        // and just look for home in a standard sub-dir location and verify
        // by looking for the config file
        if (openfireHome == null) {
            try {
                openfireHome = verifyHome("..", jiveConfigName).getCanonicalFile();
            }
            catch (FileNotFoundException fe) {
                // Ignore.
            }
            catch (IOException ie) {
                // Ignore.
            }
        }


请看verifyHome方法的第一个参数,这里配置的就是相对的路径“..”而我们重新编译的时候,配置到的路径不是这里,那么就要根据你配置的路径来修改前面的地址。
我的是这样:

[java]
view plaincopyprint?

openfireHome = verifyHome("D:\\openfire_src\\openfire_src\\target\\openfire", jiveConfigName).getCanonicalFile();<span style="font-family: Tahoma;"> </span>

openfireHome = verifyHome("D:\\openfire_src\\openfire_src\\target\\openfire", jiveConfigName).getCanonicalFile();<span style="font-family: Tahoma;"> </span>

我的配置在:openfire_src\\openfire_src\\target\\openfire文件夹下。
转自:http://hi.baidu.com/dd_taiyangxue/item/d448af3e6b02024e033edc55(有修改)


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐