MapStruct - NullPointerException
MapStruct - NullPointerException
• 개발환경
mapstruct version 1.3.0.Final
IntelliJ IDEA 2021.2.2
=> IntelliJ 사용하면서 컴파일할 때 에러 발생
java: Internal error in the mapping processor: java.lang.NullPointerException
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.createManifestUrl(DefaultVersionInformation.java:182)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.openManifest(DefaultVersionInformation.java:153)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getLibraryName(DefaultVersionInformation.java:129)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getCompiler(DefaultVersionInformation.java:122)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.fromProcessingEnvironment(DefaultVersionInformation.java:95)
at org.mapstruct.ap.internal.processor.DefaultModelElementProcessorContext.<init>(DefaultModelElementProcessorContext.java:50)
at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:218)
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:156)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:255)
at org.mapstruct.ap.MappingProcessor.process(Unknown Source)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:802)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:713)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1043)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1184)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)
at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:514)
at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:560)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:512)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:355)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:280)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:234)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1464)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1101)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1247)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:301)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
원인
jetbrains 이슈 노트를 보니 mapping processor 내에서 NPE(java.lang.NullPointerException)가 발생하여 컴파일러가 종속성 정보를 수집하지 못해 발생하는 문제
https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0
1. mapstruct 버전 업데이트
mapstruct version 1.3.0.Final 에서 1.4.1.Final 로 버전 업데이트
build.gradle
bootJar { enabled = true }
ext {
mapstructVersion = "1.4.1.Final"
}
=> 해결
2. -Djps.track.ap.dependencies=false 옵션
Build, Execution, Deployment > Compiler > User-local build process VM options (overrides Shared options)
-Djps.track.ap.dependencies=false
=> 해결
'JAVA > mapstruct, modelMapper' 카테고리의 다른 글
MapStruct 설정 (ModelMapper 대안) (0) | 2022.04.22 |
---|---|
자바 코드 매핑 vs MapStruct vs ModelMapper (0) | 2022.04.22 |