Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lombok and STS issue - Method undefined

I have STS version 3.6.3.SR1 that's based on Eclipse Luna 4.4.1.

I did the following steps:

  1. Download and run the Lombok runnable jar and gave the path of my STS.
  2. I verified the entries of vmargs, but was missing Xbootclasspath and added it resulting in

    -vmargs -Dosgi.requiredJavaVersion=1.6
    -XX:MaxPermSize=256m
    -Dorg.eclipse.swt.browser.IEVersion=10001
    -Xms512m
    -Xmx1024m
    -javaagent:C:\tools\Lombok\lombok.jar
    -Xbootclasspath/a:C:\tools\Lombok\lombok.jar
    
  3. I exit and opened the STS both from shortcut as well as the absolute location of the STS.exe.

  4. I verified the outline of my Java classes that are annotated with @Data and other Lombok annotations. I can see the getters and setters generated. Even auto assist displays the method.
  5. I did Maven → Update Project and even did a Project Clean
  6. Confirmed that the Lombok is installed as well from the 'About STS' of 'Help'.

Even after all the above activities, there are lots of compiler issues that complains undefined method getXXX() and setXXX() on all @Data or @Getter or @Setter annotations.

Maven build runs successfully and the runtime behavior is fine, as the complied class seems to have the getters and setters.

IntelliJ seems to have no porblem with this as other developers are able to use the library.

My pom.xml has the following entry as well:

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

How do I resolve?

P.S : I downloaded Eclipse Kepler build on top of STS to enable JBoss Fuse Tooling.

like image 906
Karthik R Avatar asked May 27 '15 09:05

Karthik R


4 Answers

@Karthik R, thanks for your post. The following helped me to solve the issue:

  1. Go to the Lombok page and download and double-click the jar and install in your IDE.
  2. After that, open the .ini file and see if it has javaagent and Xbootclasspath variables.

In my case, Xbootclasspath was missing and when I added that, it worked.


-Xbootclasspath/a:PATH_To_lambok.jar
like image 57
RandomWanderer Avatar answered Oct 07 '22 10:10

RandomWanderer


I added -Xbootclasspath/a:lombok.jar like naga1990 mentioned, however it still didn't solve the issue. After starting STS with -clean it did work.

like image 45
B. Ali Avatar answered Oct 07 '22 10:10

B. Ali


I had a similar problem which was resolved by changing the scope of the Lombok dependency in the pom.xml file.

Originally, the scope was "provided" and I believe I saw all the strange behaviors you described. For instance, the context-sensitive code completion pulldown included the getter and setter methods. When I chose a getter method from the pulldown, the method was inserted into the source correctly. After insertion of the getter method, STS marked the method invocation as a compilation error because it thought the method did not exist.

After removing the "provided" scope from the Lombok dependency, STS worked correctly and the getter/setter methods could be added to code, the code could be compiled/packaged and executed. Execution of the getter/setter methods worked.

like image 5
user5167428 Avatar answered Oct 07 '22 12:10

user5167428


If you already tried other methods but it still doesn't work, you can try this:

If your project is Maven-based project, STS configured it as AspectJ Capability which will conflict with Lombok.

To solve it, remove Aspects Capability by Right-click the project -> AspectJ Tools -> Remove AspectJ Capability. Hope this will work.

enter image description here

like image 3
Le Quang Nhan Avatar answered Oct 07 '22 12:10

Le Quang Nhan