Deployment for easy updating - locating all configuration outside .war possible?

We’ve just trialled XWiki as a replacement for a few existing wikis, and it looks great from a features perspective. I’m now planning out what will be the production install.

I want to make life as easy as possible for those who’ll come after me, so I’m trying to locate all config files outside of the webapp directory tree, so upgrades are as simple as “read release notes, delete old war, extract new war”. This is perfectly doable with xwiki.properties / xwiki.cfg, but I’ve not yet found a clean way to handle hibernate.cfg.xml. (I’m deploying using Jetty.)

Has anyone created a configuration like this before? Have any suggestions, either in general or for hibernate specifically?

This line of code seems to suggest you could use the xwiki.store.hibernate.path config property in xwiki.cfg: xwiki-platform/HibernateConfiguration.java at 9a2702481b88c248d50d99b3b8cbb12118e3f6cf · xwiki/xwiki-platform · GitHub

You’re using /etc/xwiki/xwiki.cfg and /etc/xwiki/xwiki.properties for xwiki.cfg and xwiki.propreties?

Yep, though I haven’t needed to edit xwiki.cfg yet, so haven’t created that one.

I saw that, but that path unfortunately looks like it’s relative to the webapp directory - notice how the default path is "/WEB-INF/hibernate.cfg.xml" (with the leading /). Unless you know otherwise?

(Here’s where that path appears to be consumed, if it helps.)

The usage is here: xwiki-platform/HibernateStore.java at b389120df967f8ee242694c8c6b6a6abf98f9e0c · xwiki/xwiki-platform · GitHub

And this is not relative but absolute, see the first try:

        File file = new File(path);
        try {
            if (file.exists()) {
                return file.toURI().toURL();
            }
        } catch (Exception e) {
            // Probably running under -security, which prevents calling File.exists()
            this.logger.debug("Failed load resource [{}] using a file path", path);
        }

It’s only if this fails that the code then tries to find it as a servlet resource (ie inside the webapp).

Yes and as already stated by Vincent, it can be done.

I’m succesfully using:

  • xwiki.cfg
  • xwiki.properties
  • hibernate.cfg.xml

from /etc - using Tomcat, but I guess that’s servlet container independent.

Just be careful that when upgrading you’ll still need to check you config files against the new ones coming in the WAR: both for new parameters you didn’t edit and for extra parameters you may have added - e.g. I have the LDAP extension and it requires adding parameters to the configuration file.