因为项目需要去研究了openfire,刚开始按照视频教程开始弄得,不知为何在eclipse里面怎么也build不起来,终于弄好了,和大家交流下经验。
材料(准备工作)
1).Openfire源码,下载我就不说了,百度即可。下载过来后解压。
2).Install4j,这个很重要,之前就是因为这个没有配置好导致失败的。因为openfire的编译是要依赖这个东西的,我们把这个东西下载过来,解压到其默认的安装路径C:/Program Files/install4j下。(我是这么做的,不这么放没试过)。
安装
1)打开eclipse->File->New Java Project
2).勾掉"Use default location",然后点击右边的"Browse...",选openfire_src_3_7_1\openfire_src目录
3).点击Finish. 到此工程已经被正常导入。
4).修改build.xml 文件找到文件
<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"/> </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"/> </or> </not> </condition>
如果你的jdk是1.8那就在后面添加<contains string="${ant.java.version}" substring="1.8"/>
5).接下来就是导包,在Package Explorer视图中,右击openfire工程,选择Properties,在弹出的对话框中选择Libraries->Add JARs..,把openfire_src_3_5_1/build/lib目录下的*.jar类库全部添加进来;选择Source标签页,Add Folder..,选中src/java目录前的复选框,点击OK,点击OK按钮。
编译阶段
(1)在eclipse中点击Window->Show View->Ant,打开Ant窗口;
(2)在Ant 视图中,单击右键,在弹出的快捷菜单中选择Add Buildfiles..;
(3)在弹出的对话框中,展开openfire/build文件夹,选择build目录下的build.xml,点击OK;
(4)在Ant视图中, 展开Openfire XMPP Server,双击 openfire(default)编译工程
(5)如果在Console视图中显示“BUILD SUCCESSFUL”就表示编译成功。
创建项目Builder
(1)在eclipse的菜单栏中,选择Run->Open Run Dialog...,在弹出的对话框左侧的树形结构中选择Java Application,单击右键,选择New创建启动配置。
(2) 在Run窗口的Main选项卡中, 修改Name文本框中的值,改成包含要启动的类的工程名openfire
(3)在Run窗口的Main选项卡中,点Browse按钮,选择openfire
(4)在Run窗口的Main选项卡中,点Search按钮,选择Main class为
org.jivesoftware.openfire.starter.ServerStarter,单击Apply按钮。(这是openfire的启动类)
(5)点击进入Arguments选项卡,在VM arguments文本框中输入
-DopenfireHome="${workspace_loc:openfire}/target/openfire"
单击Apply按钮。这个是用于eclipse执行java命令时传递的参数,这样openfire程序可以通过System.getProperty(“openfireHome”)得到openfire的本地位置。
(6)点击进入Classpath选项卡,选中User Entries,这样Advanced...就处于可用状态;点击Advanced...按钮,在Advanced Options页面,选择Add Folders, 单击OK。(默认情况下,已经将工程openfire添加到了这里,而不需要进行该项操作,如果有多个工程的时候才需要执行该项操作。)
选择openfire/src/i18n, 点OK按钮将这个文件夹加入到Classpath选项卡中;同样的方式把openfire/src/resources目录下的jar文件夹也加到Classpath选项卡中。
(11)点击进入Common选项卡中,勾选Run复选框。
点击Apply应用。
在进行这些配置之后,就算是基本完工了。
可以直接点击配置框最下方的Run按钮,或者单击菜单栏Run->Run开始跑程序。
log4j:WARN No appenders could be found for logger (org.jivesoftware.util.Log). log4j:WARN Please initialize the log4j system properly. Openfire 3.7.0 [Jun 29, 2011 1:51:19 PM] Admin console listening at <a href="http://127.0.0.1:9090">http://127.0.0.1:9090</a>
启动成功,那么在浏览器中输入http://127.0.0.1:9090测试一下吧!
错误处理
在配置完成后,有些同学启动项目并不会正常启动,而是会出现一些其他错误。
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
我们看到里面有这一行
// 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方法的第一个参数,这里配置的就是相对的路径“..”而我们重新编译的时候,配置到的路径不是这里,那么就要根据你配置的路径来修改前面的地址。
我的是这样:
openfireHome = verifyHome("D:\\openfire_src\\openfire_src\\target\\openfire", jiveConfigName).getCanonicalFile();
我的配置在:openfire_src\\openfire_src\\target\\openfire文件夹下。
相关推荐
Openfire源代码在Eclipse3.5.2中的部署、编译、运行、部署安装
Openfire源代码在Eclipse3.5.2中的部署、编译、运行、配置安装.docOpenfire源代码在Eclipse3.5.2中的部署、编译、运行、配置安装.doc
openfire配置到eclipse希望对大家有所帮主
openfire在eclipse3.5.2中的部署
NULL 博文链接:https://hbiao68.iteye.com/blog/1994957
经过各种错误之后终于成功了,缺少的jar包全部补齐,并且版本正确
详细描述openfire 源码在 Eclipse如何部署
最新的openfire源码4.0.1,导入到eclipse工程中去。
openfire部署到eclipse少的3个jar包
OpenFire二次开发环境搭建
Openfire调试、编译开发环境与安装
现在最新版的openfire源码部署到eclipse所需要的全部jar文件
openfire_4_1_3编译缺少包
本文档描述openfire从官网下载源码到搭建本地服务器流程
本文将图文介绍如何把openfire(以3.9.3为例最新版本)源码配置导入Eclipse,编译并启动的详细过程。
Openfire数据结构详解
openfire3.10.2 基于Eclipse的二次开发环境搭建缺失部分包!亲试,可以使用!
NULL 博文链接:https://beautyofprogram.iteye.com/blog/772281
Openfire安装配置手册 这个手册包括开发环境的搭建及服务器的安装配置 搭建开发环境:系统环境:windowsXP+JDK1.6+Eclipse3.6+Openfire
openfire3.10.1源码编译缺少的jar包: jetty-websocket-8.1.17.v20150415 jnsapi mina-core-1.1.7-sources...Openfire3.10beta版源码在eclipse上部署编译 : http://blog.csdn.net/haunghui6579/article/details/44513481