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.

java.lang.ClassNotFoundException: org.mapstruct.factory.Mappers

See original GitHub issue

swagger version : 3.0 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> springboot version : 2.3.0.RELEASE After packaging java -jar xxx.jar start error ` info : 2020-11-12 11:01:22.189 INFO 94730 — [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled. 2020-11-12 11:01:22.195 ERROR 94730 — [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘requestParameterMapperImpl’ defined in URL [jar:file:/Users/xingwangma/LOD/portal/designer-backend/tnt/target/lib/springfox-swagger2-3.0.0.jar!/springfox/documentation/swagger2/mappers/RequestParameterMapperImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.swagger2.mappers.RequestParameterMapperImpl]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/mapstruct/factory/Mappers at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1320) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE] at com.bigknow.tnt.TntApplication.main(TntApplication.java:26) [classes!/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [tnt-1.0-SNAPSHOT.jar:na] at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [tnt-1.0-SNAPSHOT.jar:na] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [tnt-1.0-SNAPSHOT.jar:na] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [tnt-1.0-SNAPSHOT.jar:na] Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.swagger2.mappers.RequestParameterMapperImpl]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/mapstruct/factory/Mappers at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:217) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1312) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] … 26 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/mapstruct/factory/Mappers at springfox.documentation.swagger2.mappers.RequestParameterMapper.<init>(RequestParameterMapper.java:45) ~[springfox-swagger2-3.0.0.jar:3.0.0] at springfox.documentation.swagger2.mappers.RequestParameterMapperImpl.<init>(RequestParameterMapperImpl.java:13) ~[springfox-swagger2-3.0.0.jar:3.0.0] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_191] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_191] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_191] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_191] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:204) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE] … 28 common frames omitted Caused by: java.lang.ClassNotFoundException: org.mapstruct.factory.Mappers at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_191] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_191] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_191] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_191] … 35 common frames omitted `

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:12

github_iconTop GitHub Comments

2reactions
ITman1commented, Aug 1, 2021
0reactions
Azorkcommented, Aug 15, 2022

Same issue upgrading spring boot from 2.5 to 2.6. Invalidating the cache didn’t work mapstruct excluded from spring fox (as before) using mapstruct-jdk8

Read more comments on GitHub >

github_iconTop Results From Across the Web

NoClassDefFoundError org/mapstruct/factory/Mappers #2620
When we try to deploy our SpringBoot app with Swagger 2 on AWS Lambda we get following error. Caused by: org.springframework.beans.
Read more >
ClassNotFound org.mapstruct.factory.Mappers in Docker Image
Everything works well when I run the app locally, but dockerizing the app makes Mapstruct fail. Dockerfile: FROM openjdk:15-alpine ARG JAR_FILE ...
Read more >
Implementations do not get generated - Google Groups
Caused by: java.lang.ClassNotFoundException: Cannot find implementation for example.main.CarMapper at org.mapstruct.factory.Mappers.
Read more >
mapstruct/mapstruct-users - Gitter
but it seems like everytime I change the mapper class in anyway I get this: java.lang.NoClassDefFoundError: Could not initialize class com.example.mappers.
Read more >
MapStruct 1.5.3.Final Reference Guide
MapStruct is a Java annotation processor for the generation of type-safe bean mapping classes. All you have to do is to define a...
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