powered by Jive Software

Cannot delete or refresh or update plugin because of jar file in use

In Openfire 4.6.1 it is not able possible to remove a plugin without stopping the server. The plugin destroy method is called successful, but jar files cannot be removed as the Jars are still in use by the JVM. This leaves the plugin in a indeterministic state, as it has been destroyed programmatically.

A pull request " Fix removing jars of a plugin after destroy" has been created to propose a fix for this.

With ‘remove the plugin’ you are referring to deleting the jar file from the plugins directory, I assume? I can’t recall running into this issue. I wonder if it is OS-specific.

I am running OF on Windows 10 with Java 14. I tested it java 11, same result, when trying to refresh a simple plugin like the DB access plugin:
Plugin removal: could not delete: C:\Program Files\Openfire\plugins\dbaccess\lib\dbaccess-1.2.3.jar

When using Java 8 it works.

For posterity, I’m quoting @gdt’s comment on the PR that was provided for this issue:

I’d hazard a guess that you’re running on Windows with Java 9+? There’s a known bug with Jetty that prevents the correct resources being freed up. So the JVM keeps the JAR open so it can’t be deleted on Windows. There’s a work-around for Java 8 in the code base (look for a file in the org.apache package), but it doesn’t work with Java 9+

But is it anyway not better to delegate the closing of all the resources used by the plugin to the close of the PluginClassloader? The close is more or less doing the same as the PluginManager by closing all references, but has probably a better list of all these.