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

PF4J-Spring is not compatible with Spring Boot 3 #83

Open
charbelsdk opened this issue Aug 19, 2024 · 5 comments
Open

PF4J-Spring is not compatible with Spring Boot 3 #83

charbelsdk opened this issue Aug 19, 2024 · 5 comments

Comments

@charbelsdk
Copy link

The issue is with the init method in the SpringPluginManager class.
The method is annotated by javax.annotation.PostConstruct which is deprecated and replaced by jakarta.annotation.PostConstruct.
The SpringPluginManager class is initiated without loading the plugins, thus failing to inject and load the extensions

@decebals
Copy link
Member

I think that you talk about Spring 6 not Spring 3.
According #80 it seems to work as as expected with Spring 6.

@charbelsdk
Copy link
Author

sorry, I meant spring boot 3.x.x

@charbelsdk
Copy link
Author

You can see the javax.annotation.PostConstruct in the note https://docs.spring.io/spring-framework/reference/core/beans/annotation-config/postconstruct-and-predestroy-annotations.html is deprecated.
The init method annotated PostConstruct is used to load and start the plugins.
However, since the annotation has been replaced in the new spring boot version, the method init() has not been launched.

@charbelsdk charbelsdk changed the title PF4J is not compatible with Spring 3 PF4J-Spring is not compatible with Spring Boot 3 Aug 20, 2024
@decebals
Copy link
Member

Two possible solutions:

  • create a new Spring6PluginManager that extends SpringPluginManager, override init method and add jakarta.annotation.PostConstruct annotation on it
  • add jakarta.annotation.PostConstruct annotation on SpringPluginManager (in this case both PostConstruct are added)

@decebals
Copy link
Member

But, according Spring Upgrading to Version 6.0:

The JSR-330 based @Inject annotation is to be found in jakarta.inject now. The corresponding JSR-250 based annotations @PostConstruct and @PreDestroy are to be found in jakarta.annotation. For the time being, Spring keeps detecting their javax equivalents as well, covering common use in pre-compiled binaries.

I understood your point of view, but why #80 confirmed that current version works with Spring 6 out of the box?

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

No branches or pull requests

2 participants