现在的位置: 首页 > java > openfire > 正文
” Openfire Classes Home not found. Define system property “openfireHome” or create and add the openfire_init.xml file to the classpath
2012年08月27日 openfire ⁄ 共 3118字 暂无评论

官方解决方法:

I''ve spent far too many hours trawling these forums trying to find a solution to this installation problem on a linux server:

 

" Openfire Classes Home not found. Define system property "openfireHome" or create and add the openfire_init.xml file to the classpath"

 

SOLUTION:

edit the file openfire_install_directory/bin/openfire (using any text editor)

 

insert the line "openfireHome=/install_directory/openfire" anywhere (below the JVM override comments is a good place)

eg "openfireHome=/opt/openfire"

 

我的解决方法:

 

$ vi /etc/profile
在里面加入:
export openfireHome=/opt/openfire

注销

 

解决思路:查看的openfire src

    private void locateOpenfire() throws FileNotFoundException {
        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.
            }
        }

        // 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 home is still null, no outside process has set it and
        // we have to attempt to load the value from openfire_init.xml,
        // which must be in the classpath.
        if (openfireHome == null) {
            InputStream in = null;
            try {
                in = getClass().getResourceAsStream("/openfire_init.xml");
                if (in != null) {
                    SAXReader reader = new SAXReader();
                    Document doc = reader.read(in);
                    String path = doc.getRootElement().getText();
                    try {
                        if (path != null) {
                            openfireHome = verifyHome(path, jiveConfigName);
                        }
                    }
                    catch (FileNotFoundException fe) {
                        fe.printStackTrace();
                    }
                }
            }
            catch (Exception e) {
                System.err.println("Error loading openfire_init.xml to find home.");
                e.printStackTrace();
            }
            finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                }
                catch (Exception e) {
                    System.err.println("Could not close open connection");
                    e.printStackTrace();
                }
            }
        }

        if (openfireHome == null) {
            System.err.println("Could not locate home");
            throw new FileNotFoundException();
        }
        else {
            // Set the home directory for the config file
            JiveGlobals.setHomeDirectory(openfireHome.toString());
            // Set the name of the config file
            JiveGlobals.setConfigName(jiveConfigName);
        }
    }

给我留言

您必须 [ 登录 ] 才能发表留言!

×