IntelliJ Idea mapstruct java: Internal error in the mapping processor: java.lang.NullPointerException
Asked Answered
L

6

99

After upgrading to the version 2020.3 of Idea i get a NullPointerException for the mapping processor. If anybody has a clue... Thank you!

Lethargic answered 2/12, 2020 at 16:44 Comment(0)
A
205

The solution is to update MapStruct to 1.4.1.Final or later version, see this issue for more details.

You can also add -Djps.track.ap.dependencies=false at File | Settings (Preferences on macOS) | Build, Execution, Deployment | Compiler | Build process VM options as a workaround.

Ailin answered 2/12, 2020 at 17:55 Comment(7)
After upgrading Mapstruct to 1.4.1.Final I am getting another issue which I did not get with 1.3 - "No method found annotated with @Named#value". Has anyone faced this problem yet?Centime
You just need to add the @Named annotation over the method and qualifiedByName where it was used.Overseer
IDE should not be the driver to force lib update on a project.Pronunciamento
Thanks, adding -Djps.track.ap.dependencies=false really helped me!Kehr
After upgrading Mapstruct to 1.4.1.Final I am getting another issue which I did not get with 1.3 - "No method found annotated with @Named#value", and i have this method in parent class (inheritance). these methods are there for long timeAnselmi
I would add : also update mapstruct-processor to 1.4.1.Final or later versionHemorrhoidectomy
We have the same problem with mapstruct 1.2 Final on windows, if we run the test directly on the java class. -Djps.track.ap.dependencies=false fix our problem.Prescind
K
163

If you cannot update MapStruct (my case), details here.

You have to find the exact place where put the -Djps.track.ap.dependencies=false setting (and I had hard time to figure out where).

So, as they say, a picture is worth a thousand words:

Open Preferences --> Build, Execution, Deployment --> Compiler and write ps.track.ap.dependencies=false Preferences --> Build, Execution, Deployment --> Compiler

Kallick answered 26/4, 2021 at 15:42 Comment(1)
flawless answer @KallickScript
F
19

There are several intellij bugs here. If I change the maven version 1.3.0.Final to 1.4.1.Final the intellij don't want to update the version.

Solution

  1. Upgrade the maven version to 1.4.1.Final
  2. Delete manually mapstruct 1.3.1.Final from External Libraries(Project Structure | Libraries)
  3. mvn clean package
  4. Click reload all maven projects

It works without -Djps.track.ap.dependencies=false

If you have swagger exclude mapstruct first:

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
<exclusions>
    <exclusion>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
    </exclusion>
</exclusions>
Formenti answered 11/12, 2020 at 10:3 Comment(1)
Manually removing the old version from the external libraries and reloading the Maven projects worked for me.Unaunabated
D
7

Expanding on freedev's answer. For windows users the following will be the place to go :

  1. Click on the settings gear icon on the right. enter image description here
  2. Go to settings (ctrl+A+S is a good shortcut to get here).
  3. Find Compiler under Build,Execution, Deployment in the left menu enter image description here
  4. Add -Djps.track.ap.dependencies=false in User-local build process VM options
Daugava answered 12/10, 2021 at 17:52 Comment(0)
F
4

In my case, I made these changes and it works perfectly for me.

enter image description here

enter image description here

Then I just deleted the caches and rebuilt the entire project, maybe it wasn't necessary but that worked for me.

Fortier answered 1/12, 2021 at 16:13 Comment(0)
T
1

In my case my build.gradle was misconfigured. I used some Mapstruct SPI AccessorNamingStrategy in two separat projects (command and custom-mapper) which I included twice in annotationProcessor of the build gradle. My solutions was to remove one of the annotations and it worked.

Threaten answered 17/5, 2023 at 12:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.