-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Early LocalContainerEntityManagerFactoryBean
initialization fails in case of null bean definition
#33082
Comments
I would guess that this is due to a change in Spring Framework but it is hard to be certain without some more information. You could try overriding the version of Spring Framework to see if the problem occurs with Spring Boot 3.2.5 and Spring Framework 6.1.10. If that does not help to narrow down the cause and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. |
Hey wilkinsona, Thanks for the immediate response. It seems that the change was introduced with org.springframework:spring-context version 6.1.7. My guesses are:
and
When I set the Spring Boot version to 3.3.1 and spring-context to 6.1.6, all tests are passing. |
Thanks, @emomast. Given that it works when you change the Spring Framework version, we'll transfer this to the Framework team so that they can investigate. A small sample project will help them to do that so please do create one. |
This seems to be a side effect of #32470 in 6.1.7 - any idea why the |
No. It's a strange bean to have been defined at all in a WebFlux application, particularly when using the |
We are going to leniently ignore any such type mismatch for That said, it's still worth clarifying why an |
LocalContainerEntityManagerFactoryBean
initialization fails in case of null bean definition
Looking at Boot's auto-configured |
@wilkinsona @jhoeller Thanks for taking the time to look into this issue. We are using hibernate-reactive as a provider and have the following configurations:
In the test configuration we are mocking the EntityManager:
And in the controller tests we are mocking all services and repositories. I assumed that annotating a test with WebFluxTest will skip the whole persistence configuration, so this is way I was confused why it tries to initialise an EntityManagerFactory |
Probably adding a conditional loading of the Bean only when the application is running will solve the issue? |
The method that raises this issue is:
|
You could try to watch your startup in the debugger, seeing what actually happens when your If you intentionally return |
FWIW, the latest 6.1.11 snapshot should address this issue already, leniently ignoring such a |
As a side note: Declaring the return type of your Generally, the recommendation is to make the factory method return type as specific as possible though, so |
This is the debug log when starting a test:
I added the conditional loading, so the bean is not loaded during tests anymore |
Since upgrading the Spring Boot from version 3.2.5 to version 3.3.1 the following exception is thrown for every test class annotated with @WebFluxTest. Full stacktrace below:
The text was updated successfully, but these errors were encountered: