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.

Springfox data rest: Failed to start bean 'documentationPluginsBootstrapper'

See original GitHub issue
  • Version: 2.9.2

  • Type: Question.

Hello,

I’ve been using springfox swagger with the normal JPA repositories. I’ve now included a repository which uses spring data rest. In order to have it show in the swagger ui, I required springfox-data-rest. I’ve also added @Import(SpringDataRestConfiguration.class) to my swagger configuration class.

Here is the full stacktrace:


org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: org.springframework.data.repository.support.Repositories.getRepositoryInformationFor(Ljava/lang/Class;)Lorg/springframework/data/repository/core/RepositoryInformation;
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:184) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
	at com.nwidart.techvideo.TechVideoApplication.main(TechVideoApplication.java:16) [classes/:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.3.RELEASE.jar:2.0.3.RELEASE]
Caused by: java.lang.NoSuchMethodError: org.springframework.data.repository.support.Repositories.getRepositoryInformationFor(Ljava/lang/Class;)Lorg/springframework/data/repository/core/RepositoryInformation;
	at springfox.documentation.spring.data.rest.EntityServicesProvider.requestHandlers(EntityServicesProvider.java:81) ~[springfox-data-rest-2.9.2.jar:null]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper$2.apply(DocumentationPluginsBootstrapper.java:138) ~[springfox-spring-web-2.9.2.jar:null]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper$2.apply(DocumentationPluginsBootstrapper.java:135) ~[springfox-spring-web-2.9.2.jar:null]
	at com.google.common.collect.Iterators$8.transform(Iterators.java:794) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.Iterators$5.hasNext(Iterators.java:543) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.ImmutableCollection$Builder.addAll(ImmutableCollection.java:300) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.ImmutableList$Builder.addAll(ImmutableList.java:691) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:275) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:226) ~[guava-jdk5-17.0.jar:na]
	at com.google.common.collect.FluentIterable.toList(FluentIterable.java:334) ~[guava-jdk5-17.0.jar:na]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.defaultContextBuilder(DocumentationPluginsBootstrapper.java:111) ~[springfox-spring-web-2.9.2.jar:null]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.buildContext(DocumentationPluginsBootstrapper.java:96) ~[springfox-spring-web-2.9.2.jar:null]
	at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:167) ~[springfox-spring-web-2.9.2.jar:null]
	at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	... 19 common frames omitted

Relevant pom:

    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-data-rest</artifactId>
      <version>2.9.2</version>
    </dependency>

My swagger configuration class:

package com.nwidart.techvideo.config;

import java.time.LocalDate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@Profile("!tests")
@Import(SpringDataRestConfiguration.class)
public class SwaggerConfiguration {

  @Bean
  public Docket mainConfig() {
    return new Docket(DocumentationType.SWAGGER_2)
        .select().apis(RequestHandlerSelectors.any())
        .paths(PathSelectors.regex("/api/.*"))
        .build()
        .apiInfo(apiInfo())
        .directModelSubstitute(LocalDate.class, String.class)
        .genericModelSubstitutes(ResponseEntity.class);
  }

  private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("Tech Video")
        .description("Manage tech learning sessions")
        .version("1.0")
        .contact(new Contact("Nicolas Widart", "https://nicolaswidart.com", "n.widart@gmail.com"))
        .build();
  }
}

I’ve looked through the docs but couldn’t find a lot of information on springfox data rest.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:50 (6 by maintainers)

github_iconTop GitHub Comments

13reactions
filipembcommented, Jan 6, 2019

@simbro I’ve done this:

	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger2</artifactId>
		<version>3.0.0-SNAPSHOT</version>
	</dependency>
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-data-rest</artifactId>
		<version>3.0.0-SNAPSHOT</version>
	</dependency>
	<dependency>
		<groupId>io.springfox</groupId>
		<artifactId>springfox-swagger-ui</artifactId>
		<version>2.9.2</version>
	</dependency>

    <repositories>
	<repository>
		<id>jcenter-snapshots</id>
		<name>jcenter</name>
		<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
	</repository>
</repositories>`

With: @EnableSwagger2WebMvc @Import(SpringDataRestConfiguration.class)

11reactions
Treehoppercommented, Apr 15, 2019

I recompiled springfox-data-rest 2.9.2 against spring-data-commons 2.1.4, and changed a single line in EntityContext: return entities.getPersistentEntity(actualDomainType); becomes return entities.getPersistentEntity(actualDomainType).orElse(null); Using that, SpringDataRestConfiguration works like a charm.

Since there seems to be no timeline for a 3.x release, I think quite a few people would appreciate a 2.9.3 release with this small fix. I know I would. - Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to start bean 'documentationPluginsBootstrapper' in ...
I got same issue using springfox-swagger2 and springfox-swagger-ui version(3.0.0), spring-boot version(2.6.2). The way to resolve this issue is by adding ...
Read more >
Failed to start bean 'documentationPluginsBootstrapper ...
Got the same exception with SpringBoot 2.5.4. we have a very simple spring data repository interface that extends CrudRepository. Caused by: org ...
Read more >
Failed to start bean 'documentationPluginsBootstrapper'
Spring and Swagger application Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException.
Read more >
Failed to start bean 'documentationPluginsBootstrapper' in ...
Coding example for the question Failed to start bean 'documentationPluginsBootstrapper' in spring data rest-Spring MVC.
Read more >
nested exception is java.lang.nullpointerexception - You.com
In this case, check this Spring Fox issue. Open side panel. Failed to start bean 'documentationPluginsBootstrapper' in spring data ...
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