springfox: Unable to scan documentation context default java.lang.NullPointerException: null

Please take the time to search the repository, if your question has already been asked or answered.

  • What version of the library are you using? Is it the latest version? The latest released version is Download 3.0.0-SNAPSHOT

What kind of issue is this?

  • Question. Is this a question about how to do a certain thing? no it is not.
  • Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests or steps to reproduce get fixed faster. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
    • spring xml/java config that is relevant
    • springfox specific configuration if it makes sense
    • include any output you’ve received; logs, json snippets etc.; and what the expected output should be I have a production ready Spring Boot project which until last week works fine(swagger part). And after one deploy yesterday, suddenly we cannot access the swagger page. The url was https://our-api-root/swagger-ui.html.

I see this exception when I launch the project locally(the bootrun works but with this error):

Unable to scan documentation context default java.lang.NullPointerException: null
	at springfox.documentation.spi.schema.contexts.ModelContext.<init>(ModelContext.java:89)
	at springfox.documentation.spi.schema.contexts.ModelContext.fromParent(ModelContext.java:264)
	at springfox.documentation.schema.ModelReferenceProvider.typeName(ModelReferenceProvider.java:108)
	at springfox.documentation.schema.ModelReferenceProvider.modelReference(ModelReferenceProvider.java:71)
	at springfox.documentation.schema.ModelReferenceProvider.apply(ModelReferenceProvider.java:61)
	at springfox.documentation.schema.ModelReferenceProvider.apply(ModelReferenceProvider.java:39)
	at springfox.documentation.schema.ModelProperty.updateModelRef(ModelProperty.java:128)
	at springfox.documentation.spring.web.scanners.ApiModelReader.findSameModels(ApiModelReader.java:322)
	at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:245)
	at springfox.documentation.spring.web.scanners.ApiModelReader.lambda$mergeModelBranch$8(ApiModelReader.java:192)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:192)
	at springfox.documentation.spring.web.scanners.ApiModelReader.lambda$read$4(ApiModelReader.java:145)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:144)
	at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:144)
	at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:69)
	at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.scanDocumentation(AbstractDocumentationPluginsBootstrapper.java:97)
	at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:83)
	at springfox.documentation.spring.web.plugins.SpringIntegrationDocumentationPluginsBootstrapper.contextRefreshedEventExecute(SpringIntegrationDocumentationPluginsBootstrapper.java:81)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:305) [4 skipped]
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:190)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:153)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.finishRefresh(ReactiveWebServerApplicationContext.java:129)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at eu.vptech.checkoutexp.checkout.CheckoutApplication.main(CheckoutApplication.java:11)
- [ ] if you have a repo that demonstrates the issue for bonus points! See [this example](https://github.com/springfox/springfox/issues/494) 

Tried to reproduce it with a simple demo project but failed.

  • Feature Request. Start by telling us what problem you’re trying to solve. Often a solution already exists! Don’t send pull requests to implement new features without first getting our support. Sometimes we leave features out on purpose to keep the project small.

Please do consider starring this repository if you do like this project and find it useful.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 53 (31 by maintainers)

Commits related to this issue

Most upvoted comments

I think that is better to check for NULL and then use LOG.warn() . I will return that fuse, I shouldn’t have removed it. That is refactor issue. Will submit a PR tomorrow.

Adding @ApiModel is not required, just if you wish. Merging algorithm must render declaration as is.

@WesleyBlancoYuan could you confirm this is fixed in the latest SNAPSHOT build? /c @MaksimOrlov

Yes it is. I now close this.

I finally managed to reproduce the problem. That happens due to aggregation of Mono and ResponseEntity i.e. Mono<ResponseEntity<OrderDTO>> in that case all dependent models of OrderDTO is being lost.

Thanks again for the report , will fix that in the next few days.

@knunu, thanks for feedback.