pf4j: Cannot remove plugin jar file after unloading
Hi, I’m using pf4j 2.2.0 maven dependency in my project. My web app allows an administrator user to add and drop plugins at runtime. These are the steps to “add” a plugin:
- A .jar file is selected in the UI and uploaded to server
- A call to
loadPluginis issued by passing the path where jar was stored - Plugin features are shown in the UI (basically the info found in the plugin descriptor)
- The admin determines whether to onboard this plugin or reject it.
When the plugin is accepted I simply call start method and all is fine. When the user rejects it, I do call unloadPlugin, but then I need to remove the corresponding jar file. Here’s what I am getting:
java.nio.file.FileSystemException: ...file.jar: The process has no access to the file because it's being used by another process
...
at java.nio.file.Files.delete(Files.java:1126) ~[?:1.8.0_65]
Seems very similar to this which was closed months ago.
Any idea on how to workaround it?
Thanks.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (8 by maintainers)
I suppose that your application runs on an Windows machine. Is it correct?
Hi, I coded a minimalistic example, and it’s embarrassing… it works perfectly
In my app I am doing some other custom manipulation of plugin jars for a variety of reasons, however it seems I need to double check if some stream is not getting closed there. I think you may close this issue.
Thanks for your help