java.lang.ClassNotFoundException: org.jivesoftware.openfire.gateway.util.Log4JToOpenfireAppender

I get this error when starting Openfire 3.4.1. I can see that the class is contained in /plugins/gateway/lib/plugin-gateway.jar, but reading the code for PluginClassLoader I see that this jar is specifically excluded from the classpath:

// Do not add plugin-pluginName.jar to classpath.
if (!jars[i].getName().equals(“plugin-” + directory.getName() + “.jar”)) {
addURL(jars[i].toURL());
}

Is this a known problem?

Hi Michael,

That part of the code will get executed if you’re in the “development mode” i.e. when you specify gateway.webRoot and gateway.classes in your system property, but this isn’t a case if you just run Openfire as normally and you download/install gateway plugin unmodified.

Are you doing any plugin development when you see this error?

Could it be that you don’t have log4j.jar in /plugins/gateway/lib/ ?

I’m not in development mode and I can see by stepping through the code that plugin-gateway.jar does seem to be added to the classpath. I have a custom build of openfire 3.4.1 which I’ve created by adding my customisations (provides for vcard, user, auth and group) to the downloaded source for 3.4.1. I do also have my own plugin but it’s not in development mode either.

The gateway plugin does have log4j.jar in its lib directory. I also have log4j.jar in the openfire/lib directory because it’s used by my customisations - I wonder if that might cause the problem?

Hi Michael,

So it’s not the development mode issue.

Since you’ve modified Openfire source, it may be harder for people other than yourself to narrow down the problem especially when it relates to your modifications. Anyway, does it work without modification? If it doesn’t it could be something related to the JVM or OS you’re using. What does the detail stack trace say in your error.log?

BTW, I don’t think where you place log4j.jar makes any difference.