Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Extensions are not detected with ClassLoadingStrategy.APD #449

Open
bhanu8784 opened this issue Jun 4, 2021 · 6 comments
Open

Plugin Extensions are not detected with ClassLoadingStrategy.APD #449

bhanu8784 opened this issue Jun 4, 2021 · 6 comments
Labels

Comments

@bhanu8784
Copy link

Hi,

I am trying to use pf4j/pf4j: Plugin Framework for Java (PF4J) (github.com) with spring and wanted to use Application first strategy for class loader.

Issue I am observing is whenever I use ClassLoadingStrategy.APD then extensions are not identified ( I mean not able to read extensions.idx file from plugin jar). Hence pluginmanager.getExtensions(pluginid) will always return empty.

  1. My application jar (spring boot jar) also has extensions.idx which is always getting created without any extensions as I don't have any extension in my application.
  2. My plugin jar also has extensions.idx with extension classes as expected.

I am setting ClassLoadingStrategy.APD for PluginClassLoader.

My Obervsation:

When extensionfinder trying to read extensions.idx it will always find one which is in my application.jar and that will not have any extensions. (getResource() method in the PluginClassloader will follow APD while loading the resource as it finds one in parent it will not attempt to load extensions from extensions.idx present in plugin jar)

Thank you
BhanuKiran

@decebals
Copy link
Member

decebals commented Jul 7, 2021

I can confirm that is a bug but it's somehow expected.
It's an extensions.idx file in app and other extensions.idx in plugin. If ClassLoadingStrategy.APD is used, then the extensions.idx of app is found first.
I will take a look on the MR proposed by you.

@alegacy
Copy link

alegacy commented Oct 26, 2022

Any progress on this? I seem to have hit the same issue. I am seeing a META-INF/extensions.idx that appears to be coming from the pf4j-spring-0.7.0.jar file which is getting used when I use the APD loading strategy. I am not clear on why that jar file has its own extensions.idx file.

I posted a question on google groups just now:
https://groups.google.com/g/pf4j/c/52MRpvTmMOQ

2022-10-26 16:17:52.601 DEBUG 60535 --- [           main] org.pf4j.LegacyExtensionFinder           : Reading extensions storages from classpath
2022-10-26 16:17:52.602 DEBUG 60535 --- [           main] org.pf4j.LegacyExtensionFinder           : Read 'file:/Users/foo/pf4j-test-app/build/libs/pf4j-test-app.jar!/BOOT-INF/lib/pf4j-spring-0.7.0.jar!/META-INF/extensions.idx'

@decebals
Copy link
Member

@alegacy I didn't find a good solution yet.
In your case the solution is relative simple because from I see the presence of META-INF/extensions.idx in pf4j-sping is useless (no extensions defined). So, we can fix this aspect in pf4j-spring, and that it's all.

@alegacy
Copy link

alegacy commented Oct 27, 2022

@decebals Thanks for confirming. I have manually removed the META-INF/extensions.idx file from the pf4j-spring jar in my gradle cache and confirmed that the plugin extensions are now loaded while using the ClassLoadingStrategy.APD.

While we wait for an updated pf4j-spring jar to appear on maven central is there a gradle workaround that could be used to exclude that file automatically either when importing the dependency or when building the bootJar?

@decebals
Copy link
Member

@alegacy Released pf4j 3.8.0 and pf4j-spring 0.8.0 are now available on Maven Central repository.

@alegacy
Copy link

alegacy commented Oct 28, 2022

Thank you @decebals !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants