question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameter 0 of constructor in springfox.documentation.spring.data.rest.EntityServicesProvider required a bean of type 'javax.servlet.ServletContext' that could not be found.

See original GitHub issue

From a few days ago to now, the following error starts to happen.

Parameter 0 of constructor in springfox.documentation.spring.data.rest.EntityServicesProvider required a bean of type ‘javax.servlet.ServletContext’ that could not be found.

The problem occurs mainly because here, in my company, we have a common module that is responsible for including a few libraries. This module is used by both Web SpringBoot Applications and Non-Web SpringBoot Applications.

I’ve have validated that the EntityServicesProvider is always created even if it’s not a Web Application Project. Of course, because it is being included by the dependency imported by the common module. For sure, I could exclude the Springfox lib using Maven, but why not conditionate the SpringDataRestConfiguration to the @ConditionalOnWebApplication???

Just an Idea.

SpringDataRestConfiguration is working correctly because RepositoryRestConfiguration it’s being imported by the common module. Imagine the following situation: (a) my-application (there are a lot of (a) apps) imports (b) my-common, which also imports © a bunch of libraries, including spring-data-jpa, spring-data-rest, … and also, springfox-*. This common is a module used to concentrate the most used libraries in one place. All other applications import it to make things easier concerning dependency management. Almost all applications are a Web Application, but a little number of them are Non-Web. In this case, we start the application with:

new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);

RepositoryRestConfiguration is in the Classpath but it is not being created because is a Non-Web application, although SpringDataRestConfiguration is still being loaded. Even in a Non-Web environment.

About the common. Don’t judge me. It isn’t my idea hehehe! This problem starts to happen a few days ago. I’ve been used version 3.0.0-SANPSHOT since the beginning of the year.

There is a project attached showing the error.

The solution could be: sample-springfox.zip

@Configuration
@ComponentScan(
    basePackages = {"springfox.documentation.spring.data.rest"}
)
@Incubating("2.5.0")
@ConditionalOnWebApplication
@ConditionalOnClass({RepositoryRestConfiguration.class})
public class SpringDataRestConfiguration {
    ...
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
desideraticommented, Jul 13, 2020

Heyyy, it’s working 😉 Thanks for everything

1reaction
dilipkrishcommented, Jul 11, 2020

That helped fixing it. Let me know how that works for you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Swagger Error with version upgrading version > 2.6.1
BeanInstantiationException : Failed to instantiate [springfox.documentation.spring.data.rest.BasePathAwareServicesProvider]: No default ...
Read more >
Documenting a Spring Data REST API with Springfox and ...
A tutorial on how to document a REST API created with Spring Data REST ... a Swagger documentation for certain Spring beans and...
Read more >
Springfox integration to generate REST documentation
Hello, we're trying to integrate Springfox ... rest-api ... NoSuchBeanDefinitionExcept ion: No qualifying bean of type 'javax.servlet.
Read more >
F.A.Q - Springdoc-openapi
How can I define multiple OpenAPI definitions in one Spring Boot project? ... OpenAPI definitions, a bean of type GroupedOpenApi needs to be...
Read more >
swagger documentationpluginsbootstrapper - You.com
Failed to start bean 'documentationPluginsBootstrapper' Spring boot Swagger implementation using Spring Fox? Asked Sep 21, 2020 • 2 votes 1 answer. QUESTION
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found