Search code examples
javabuilderlombok

Lombok in project generated by Spring Initializr (LombokProcessor could not be initialized)


I would like to create a class with ownBuilderMethod from Lombok. After click Shift+F10 (launch app) I get the error:

Warning:(22, 8) java: lombok.javac.apt.LombokProcessor could not be initialized. Lombok will not run during this compilation: java.lang.IllegalArgumentException: com.sun.tools.javac.main.DelegatingJavaFileManager$DelegatingSJFM extends com.sun.tools.javac.main.DelegatingJavaFileManager implements javax.tools.StandardJavaFileManager
    (..)

And:

Error:(39, 19) java: cannot find symbol
symbol:   class ProfileBuilder
location: class io.github.plkpiotr.fifabackend.model.Profile

Plain @Builder without this builderMethodName works properly, but with "ownBuilderMethod" doesn't.

Source code:

package io.github.plkpiotr.fifabackend.model;

import lombok.*;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.util.UUID;

@Entity
@Table(name = "profiles")
@Data
@Builder(builderMethodName = "ownBuilderMethod")
//@AllArgsConstructor
//@NoArgsConstructor
public class Profile {
    @Id
    private String id;

    @NotNull
    @Pattern(regexp = "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$")
    private String nick;

    @NotNull
    private String password;

    @NotNull
    @Email
    private String email;

    public static ProfileBuilder builder() {
        return ownBuilderMethod()
                .id(UUID.randomUUID().toString());
    }
}

Solution

  • To fix the fact that LombokProcessor could not be initialized you have to change dependency of Lombok in Maven (pom.xml file):

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    

    for:

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.22</version>
    </dependency>