NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
See original GitHub issueHi, I’m getting thw following error using the last library version as shown bellow: NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
JDK 15
POM
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.9.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR6</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-oas</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
Swagger config class
//@EnableSwagger2
//@EnableOpenApi
@Configuration
@EnableWebMvc
public class SwaggerConfig {
@Value( "${info.app.name:ServiceTitle}" )
private String title;
@Value( "${info.app.description:ServiceDescription}" )
private String description;
ApiInfo apiInfo() {
return new ApiInfoBuilder().title(title)
.description(description).license("")
.licenseUrl("http://unlicense.org").termsOfServiceUrl("").version("1.0.0")
.contact(new Contact("", "", "")).build();
}
@Bean
public Docket customImplementation() {
return new Docket(DocumentationType.OAS_30).select()
.apis(RequestHandlerSelectors.basePackage("com.application.api")).build()
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
.apiInfo(apiInfo());
}
}
The error I get:
2020-08-18 13:01:39.119 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'swagger2ControllerMapping' defined in class path resource [springfox/documentation/swagger2/configuration/Swagger2DocumentationConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'swagger2ControllerMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
2020-08-18 13:01:39.128 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown initiated...
2020-08-18 13:01:39.148 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-2 - Shutdown completed.
2020-08-18 13:01:39.177 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2020-08-18 13:01:39.184 [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
2020-08-18 13:01:40.229 [main] WARN z.r.AsyncReporter$BoundedAsyncReporter - Timed out waiting for in-flight spans to send
2020-08-18 13:01:40.231 [main] INFO o.a.catalina.core.StandardService - Stopping service [Tomcat]
2020-08-18 13:01:40.236 [main] WARN o.a.c.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [spring.cloud.inetutils] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base@15-ea/java.net.Inet6AddressImpl.getHostByAddr(Native Method)
java.base@15-ea/java.net.InetAddress$PlatformNameService.getHostByAddr(InetAddress.java:938)
java.base@15-ea/java.net.InetAddress.getHostFromNameService(InetAddress.java:662)
java.base@15-ea/java.net.InetAddress.getHostName(InetAddress.java:605)
java.base@15-ea/java.net.InetAddress.getHostName(InetAddress.java:577)
org.springframework.cloud.commons.util.InetUtils$$Lambda$113/0x0000000800c82170.call(Unknown Source)
java.base@15-ea/java.util.concurrent.FutureTask.run(FutureTask.java:264)
java.base@15-ea/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
java.base@15-ea/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
java.base@15-ea/java.lang.Thread.run(Thread.java:832)
2020-08-18 13:01:40.255 [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-18 13:01:40.259 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'swagger2ControllerMapping' defined in class path resource [springfox/documentation/swagger2/configuration/Swagger2DocumentationConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'swagger2ControllerMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:655)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:635)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
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 com.demetra.boot.starter.MicroServiceApplicationBoot.main(MicroServiceApplicationBoot.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:109)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'swagger2ControllerMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650)
... 27 common frames omitted
Caused by: java.lang.NoClassDefFoundError: springfox/documentation/spring/web/PropertySourcedRequestMappingHandlerMapping
at springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration.swagger2ControllerMapping(Swagger2DocumentationConfiguration.java:56)
at springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration$$EnhancerBySpringCGLIB$$48c5981c.CGLIB$swagger2ControllerMapping$0(<generated>)
at springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration$$EnhancerBySpringCGLIB$$48c5981c$$FastClassBySpringCGLIB$$22c6fd9e.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration$$EnhancerBySpringCGLIB$$48c5981c.swagger2ControllerMapping(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 28 common frames omitted
Caused by: java.lang.ClassNotFoundException: springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 39 common frames omitted
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10
Top Results From Across the Web
Spring Boot java.lang.NoClassDefFoundError - Stack Overflow
I finally solved my problem. I was using Guava to find all classes annotate by @WebService and i create the bean. But all...
Read more >Cool IT Help - YouTube
Create JavaFX Application using Eclipse IDE (2021) and Scene Builder · Difference between ClassNotFoundException and NoClassDefFoundError · Java ...
Read more >org/springframework/data/jdbc/repository/config ... - Reddit
NoClassDefFoundError : org/springframework/data/jdbc/repository/config/AbstractJdbcConfiguration. I want to write some tests to my repository ...
Read more >How to fix java.lang. ClassNotFoundException: org ... - Crunchify
How to fix HTTP Status 404 Error while running Spring MVC project? I have been running Spring MVC projects since last ~8 years...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Wtf… how is it that generating a swagger page needs 6 separate dependencies?
@coding-with-binaries I added this dependencies and it worked
and changed SwaggerConfig.java like this: