Mapstruct and InteliJ - Exception sometimes with inherited fields during `build project`

4.2k views Asked by At

Problem:

We have a class that extends another class and inherits some fields. clean install in maven is working perfectly and the impl mapper classes are being generated.

Sometimes other people (students, etc) have changed the mappers, I notice that the build/make project in InteliJ is breaking.

I am getting an error such as the following stacktrace:

    Error:(12, 8) java: Internal error in the mapping processor: java.lang.NullPointerException            at
 org.mapstruct.ap.internal.model.source.SourceReference.copyForInheritanceTo(SourceReference.java:333)  at
 org.mapstruct.ap.internal.model.source.Mapping.copyForInheritanceTo(Mapping.java:462)      at
 org.mapstruct.ap.internal.model.source.MappingOptions.applyInheritedOptions(MappingOptions.java:279)     at
 org.mapstruct.ap.internal.processor.MapperCreat
ionProcessor.mergeInheritedOptions(MapperCreat
ionProcessor.java:457)                  at
 org.mapstruct.ap.internal.processor.MapperCreat
ionProcessor.getMappingMethods(MapperCreat
ionProcessor.java:274)                  at
 org.mapstruct.ap.internal.processor.MapperCreat
ionProcessor.getMapper(MapperCreat
ionProcessor.java:152)                  at
 org.mapstruct.ap.internal.processor.MapperCreat
ionProcessor.process(MapperCreat
ionProcessor.java:123)                  at
 org.mapstruct.ap.internal.processor.MapperCreat
ionProcessor.process(MapperCreat
ionProcessor.java:80)                  at
 org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:280)    at
 org.mapstruct.ap.MappingProcessor.processMapperTypeElement(MappingProcessor.java:260)              at
 org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:226)      at
 org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:162)         at
 com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)         at
 com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)                  at
 com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)                  at
 com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)          at
 com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)      at
 com.sun.tools.javac.main.JavaCompiler.processAnnotat
ions(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

And here is where jetbrains part is:

 org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:190)                 at
 org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:483)             at
 org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:339)     at
 org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:256)      at
 org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:214)           at
 org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1263)  at
 org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:940)            at
 org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1012)               at
 org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:903)           at
 org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:736)              at
 org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:384)      at
 org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:192)             at
 org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:138)                  at
 org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:295)                  at
 org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)            at
 org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:236)               at
 org.jetbrains.jps.service.impl.SharedThreadPoolImpl.lambda$executeOnPooledThread$0(SharedThreadPoolImpl.java:42)                  at
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)       at
 java.util.concurrent.FutureTask.run(FutureTask.java:266)            at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)     at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)     at
 java.lang.Thread.run(Thread.java:745)  

Question:

So, is there some type of configuration change I need to make to InteliJ???

Current Workaround:

What is working for me now, is to go to the Spring Boot Run Configuration and in the section Before Launch: Activate tool window I have made a change.

I have removed Build Project. So the target directory generated from maven is used. Inteli J make command is used only to rebuild and hotswap changed classes.

0

There are 0 answers