springfox: CachingModelPropertiesProvider - NullPointerException after lazy load configuration
I’m facing the issue #1207 too, now with newer versions of springfox.
Springfox Versions:
Spring Boot Version: 2.1.2-RELEASE
(using spring cloud parent Greenwich.RELEASE
.
Spring Version: 5.1.4
I use undertow
and everything works without setting all beans to lazy init.
After setting all spring beans to lazy load to improve the startup time, swagger is reporting error calculating properties for models. The cause is a NullPointerException because the objectMapper are null.
There is any kind of workaround this springfox issue? Or even a better way to set lazy initialization that works with swagger.
I have a BeanFactoryPostProcessor
implemented that loop for all beans setting it to lazy init.
Thank you.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 12
- Comments: 28 (1 by maintainers)
@guisesterheim this exactly what I explained on my description: we can’t have lazy initialization if we want to use springfox.
This is exactly what we need to fix here. I want lazy initialization and springfox to work together.
Yeah with spring-boot really advertising lazy initialization as of 2.2 this issue really needs to be resolved.
This project should be archived. I suggest using the following project: https://github.com/springdoc/springdoc-openapi
A migration guide to leave springfox: https://springdoc.org/#migrating-from-springfox
All my models appear empty, when I put the bare bones:
new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build()
I got some new ones from Spring itself
2020-01-01 07:27:25.368 WARN 5972 — [ restartedMain] s.d.s.p.CachingModelPropertiesProvider : Exception calculating properties for model(org.springframework.web.servlet.ModelAndView) -> ModelContext{groupName=default, type=org.springframework.web.servlet.ModelAndView, isReturnType=true}. java.lang.NullPointerException 2020-01-01 07:27:25.372 WARN 5972 — [ restartedMain] s.d.s.p.CachingModelPropertiesProvider : Exception calculating properties for model(org.springframework.web.servlet.ModelAndView) -> ModelContext{groupName=default, type=org.springframework.web.servlet.ModelAndView, isReturnType=true}. java.lang.NullPointerException