`
xxtianxiaxing
  • 浏览: 752745 次
  • 性别: Icon_minigender_1
  • 来自: 陕西
社区版块
存档分类
最新评论

openfire 源码 部署

阅读更多
1.复制src\java下所有东西;
2.openfire\src\i18n, 点OK按钮将这个文件夹加入到Classpath选项卡中;
3.同样的方式把openfire\src\resources目录下的jar文件夹也加到Classpath选项卡中。
4.openfire的起始类为org.jivesoftware.openfire.starter.ServerStarter.java,但是直接运行此类却有问题,因为此类是针对Openfire安装包而设计的,此类的功能是将所用到的JAR文件解压并将class文件加载到虚拟机中,而我们要用的却是源代码中我们自己编译好的class文件。所以,我们需要一个新的启动类。
一个简单的实现方法就是把src/java下的东西复制到我创建的java project下的src里了,并修改org.jivesoftware.openfire.starter包中ServerStarter.java类的源代码,具体如下(当然最好是与ServerStarter.java中的方法一样,用自定义的ClassLoader来将XMPPServer.class加载到虚拟机中)
package org.jivesoftware.openfire.starter;
import org.jivesoftware.openfire.XMPPServer;
public class StandaloneStarter {

public static void main(String[] args) {

XMPPServer server = new XMPPServer();

}
}
这样程序就可以跑起来了,最后的问题就是配置文件路径的问题。
5.配置文件路径
如果文件路径配置不正确(即Openfire的Home没有设定或者设置不正确),就可能在运行时出现如下所示的问题:
Could not locate home
java.io.FileNotFoundException......

ERROR 12114 [Jive-ERR] (): 
java.io.FileNotFoundException: XML properties file does not exist: openfire.xml........
在XMPPServer类中有一个locateOpenfire方法,这个方法就是设置openfireHome属性。
第1部分的代码如下:
String jiveConfigName = "conf" + File.separator + "openfire.xml";
// First, try to load it openfireHome as a system property.
if (openfireHome == null) {
String homeProperty = System.getProperty("openfireHome");
try {
if (homeProperty != null) {
openfireHome = verifyHome(homeProperty, jiveConfigName);
}
}
catch (FileNotFoundException fe) {
// Ignore.
}
}
是在环境变量设置了Openfire的Home的情况下寻找openfire.xml文件

你可以更改第二部分的代码让Openfire找到Home:
// 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("C:\\Program Files\\Openfire", jiveConfigName).getCanonicalFile();
}
catch (FileNotFoundException fe) {
// Ignore.
}
catch (IOException ie) {
// Ignore.
}
}
这部分默认是找当前文件路径,你可以修改它为你安装openfire的路径,这样问题就可以解决了。
6.将新建的工程目录下src/web/WEB-INF/classes/openfire_init.xml导入到eclipse的查询路径里,如将src/web/WEB-INF/classes目录作为eclipse的源目录,这样openfire_init.xml自动copy到$openfire_home/classses下面,将openfire_init.xml中的openfireHome设置为$openfire_home
修改org.jivesoftware.openfire.starter.ServerStarter中的如下两个field,
private static final String DEFAULT_LIB_DIR = "../lib";
private static final String DEFAULT_ADMIN_LIB_DIR = "../plugins/admin/webapp/WEB-INF/lib";
改成:
private static final String DIR_PREFIX = "$openfire_home";
// to be your own openfire_home
private static final String DEFAULT_LIB_DIR = DIR_PREFIX + "lib";
private static final String DEFAULT_ADMIN_LIB_DIR = DIR_PREFIX + "plugins/admin/webapp/WEB-INF/lib";
现在还不知道这里为什么要这样做?????


  • 大小: 8.8 KB
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics