Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

一、环境


Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

一、下载Openfire源码

htp://www.igniterealtime.org/downloads/source.jsp

openfire_src_3_9_1.zip 点击下载

下载完毕后解压资源到某个路径下

relsese版本下载连接:

http://www.igniterealtime.org/downloads/index.jsp

二、编译源码

打开Eclipse,新建工程,use default location选择openfire解压路径

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境



新建编译项

Window->Show view->Ant

ant窗口中点击Add buildfiles,在buildfile selection窗口中选择openfile工程中的build.xml,点击OK

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

展开Openfire XMPP Server项,在众多项中选择openfire[default],右键Run as->Ant Build进行编译。

编译通过后提示BUILD SUCCESSFUL

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

编译成功后,工程目录结构下多出两个目录targetwork

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

三、添加lib

将刚才生成的目录target/openfire/lib下所有jar包添加到工程中

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境


四、配置run configurations

Main标签页的Main class点击Search,搜索ServerStarter,选中ServerStarter – org.jivesoftware.openfire.starter,勾选Include system libraries when searching for a main class

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Arguments标签页中VM arguments属性填入:-DopenfireHome="${workspace_loc:openfire}/target/openfire

注意:冒号后的openfire是工程名,与你当前的工程名保持一致,否则运行会出现异常。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Classpath标签页中,选中User Entires,点击Advanced,选择Add Folders,点击OK,分别添加openfire/src/i18nopenfire/src/resources文件夹。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Common标签页中,选中DebugRun,保存配置。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

点击Run按钮运行,编译完成了,应该不是太难。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

五、运行openfire管控后台

在浏览器中输入http://127.0.0.1:9090,进入后台管理界面。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

六、配置管控平台

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

这里的域名可以任意填写,就是服务器名称,客户端向好友发消息时会用到该名称,比如向好友gerry发消息时,代码中可能会这样写gerry@simon

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

选择标准数据库连接,使用了外部的MySQL数据库,本地需要安装后进行连接。

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

这里选择了MySQL作为数据库,需安装MySQL,并创建openfire数据库

数据库URL:替换本地ip和数据库名,去除左[]括号

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境


七、下载Spark源码

参考Spark编译运行

http://community.igniterealtime.org/docs/DOC-1020

SVN上获取源码

http://www.igniterealtime.org/downloads/source.jsp

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

八、导入Spark源码到Eclipse

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

九、编译Spark源码

添加Ant编译文件

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

运行ant编译

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

当前ant版本为1.9.x,编译会出错,要求Ant版本1.6.x1.7.xJAVA版本1.5.x1.6.x

BUILD FAILED

/usr/gym/pm/tech/Openfire/Spark/spark_2_5_6_branch/build/build.xml:129: Must use Ant 1.6.x or 1.7.x to build Spark

可以修改build.xml中对antjava版本的要求。

<condition property="ant.not.ok" value="true">

<not>

<or>

<contains string="${ant.version}" substring="1.6"/>

<contains string="${ant.version}" substring="1.7"/>

<contains string="${ant.version}" substring="1.8"/>

<contains string="${ant.version}" substring="1.9"/>

</or>

</not>

</condition>

<condition property="java.not.ok" value="true">

<not>

<or>

<contains string="${ant.java.version}" substring="1.5"/>

<contains string="${ant.java.version}" substring="1.6"/>

<contains string="${ant.java.version}" substring="1.7"/>

<contains string="${ant.java.version}" substring="1.8"/>

</or>

</not>

</condition>

ant下载地址:http://ant.apache.org/bindownload.cgi

再次编译则编译通过,项目工程中多出target目录

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

十、配置Run Configurations,运行

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境

Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境


保存配置,点击Run

会有提示错误

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.jivesoftware.launcher.Startup.start(Startup.java:83)

at org.jivesoftware.launcher.Startup.main(Startup.java:33)

Caused by: java.lang.Error: Unresolved compilation problems:

GSSAPIConfiguration cannot be resolved to a type

GSSAPIConfiguration cannot be resolved to a type


解决方案:

Spark/spark_2_5_6_branch/src/java中的GSSAPIConfiguration.java移动到Spark/spark_2_5_6_branch/src/java/org/jivesoftware目录下,再次编译-RUN

参考:

http://community.igniterealtime.org/thread/38439


Ubuntu12.04(64bit)上部署编译运行Openfire+Spark环境


转载于:https://my.oschina.net/stevegym/blog/207892