Comments (6)
I think I see the issue, because the SpringPlugin class belongs to the application's ClassLoader, and i'm implementing the createApplicationContext
method for it, but i'm trying to start an application context with a different version of Spring (provided by the plugin's class loader).
I think for my use case I should actually avoid using pf4j-spring, as my plugin is an executable spring application also but I want the possibility for the version of spring to diverge between the plugin and the application (hence why I don't want Spring libraries to be provided by the application). I should do what spring-cloud-function-deployer does and implement the plugin as a standard plugin which starts the plugin spring application reflectively (i.e. https://github.com/spring-cloud/spring-cloud-function/blob/8dee0b94c70735b2c05731924650e89ad28eb526/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionArchiveDeployer.java#L253)
Thanks for the advise.
from pf4j-spring.
@jamesmmchugh See documenttion about plugin ClassLoader.
By default, PF4J uses child (plugin) first class loading strategy. I think that in your case you need to switch to parent (application) first class loading strategy.
For introduction in problem, you can take a look on pf4j/pf4j#392.
In the latest versions of PF4J was introduced ClassLoadingStrategy
. For more information see pf4j/pf4j#385.
from pf4j-spring.
How is it meant to behave if your plugin uses the same class (but a different version) internally, from one being used and loaded by the application?
from pf4j-spring.
Your case (error) is particular:
loader org.pf4j.PluginClassLoader @7d3fb0ef wants to load interface org.springframework.context.ApplicationContext. A different interface with the same name was previously loaded by 'app'. (org.springframework.context.ApplicationContext is in unnamed module of loader 'app')
I don't think that you want to use a different version of Spring (core/context) in app and plugins. I think that scope of the Spring library/dependency should be "provided" in plugins.
In general I say that it's normal to have different versions of the same library in multiple plugins but I don't think that this library could be Spring (core/context) because it is part of framework (pf4j-spring).
from pf4j-spring.
Is there any facility in PF4J already to handle spring-boot executable jars as plugins - given they are packaged differently from a standard JAR? If not perhaps this would be a nice extension in the future, and also starting the spring-boot executable plugin reflectively as per the example above.
from pf4j-spring.
Take a look at #48. Unfortunately I don't use Spring Boot in my projects, so I cannot help you. Maybe you can work together with @fabioformosa to a PR. Thanks!
from pf4j-spring.
Related Issues (20)
- SpringPlugin start/stop/start results in Exception HOT 2
- Loading plugin on-runtime : Ambiguous hander methods mapped & ConcurrentModificationException when unregistering routes
- I use it SpringPluginManager, It seems to be a single case. HOT 4
- How to update the βList<Greeting>β while some plugins unloaded and deleted? HOT 4
- How to add integration tests for the plugin?
- self contained example HOT 1
- Jpa in plug-in not working HOT 1
- Hi author, Can I send a pull request to PF4J-Spring to support the Spring parent-child context οΌ
- Injecting beans from plugin in application doesn't work HOT 2
- run exception on pf4j-spring demo
- pf4j plugin needs to refresh and detect changes automatically with spring HOT 6
- How to get this repo versions release notes? HOT 2
- Problems with Using Pf4j-Spring HOT 1
- The real implementation cannot be accessed through the api interface. HOT 2
- When 'spring-boot-devtools' is introduced in the project, the extensions are not available. HOT 2
- How do you extend with kafka HOT 1
- Retrieve Resource from Inside Plugin HOT 1
- When will plan support Spring6.x ? HOT 6
- Is there a plan to release version 0.9.0 or 0.8.1 to incorporate the changes from commit 5d26e9b? HOT 2
- ExtensionsInjector register extension duoble
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pf4j-spring.