Lombok and STS issue - Method undefined - eclipse

I have STS version 3.6.3.SR1 that's based on Eclipse Luna 4.4.1.
I did the following steps:
Download and run the Lombok runnable jar and gave the path of my STS.
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
I exit and opened the STS both from shortcut as well as the absolute location of the STS.exe.
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.
I did Maven → Update Project and even did a Project Clean
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.

#Karthik R, thanks for your post. The following helped me to solve the issue:
Go to the Lombok page and download and double-click the jar and install in your IDE.
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

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.

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.

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.

I solved it as follows...
1. downloaded UI Swing application of lombok ... namely lombok.jar
2. started it and entered path of sts manually till sts.exe, i.e. complete folder which contains sts.exe
3. clicked on update/install
4. while doing all above 3 steps, make sure that sts is not running at all.
5. start sts
6. clean build the project.

This if for eclipse/STS
1. Close your sdk
2. download lombok jar
3. double click it or run it with java.exe
4. Make sure below line should get added in .ini file
-javaagent:\lombok.jar
5. add below line if missing add yourself
-Xbootclasspath/\lombok.jar
6. Open your sdk. Go to Help->About. You should see below line
"Lombok v1.18.6 "Envious Ferret" is installed. https://projectlombok.org/"
7. Clean your project.
8. Build it again.

Try to close your project, open it again and check. It worked for me.

After adding javaagent and Xbootclasspath values. Close STS completely and start again. Don't try to restart, it will not work

I had the same problem and it turns out that lombok is not working only when I'm starting STS from desktop shortcut which I created earlier (before loombok installed). I removed shortcut and created once again and lombok works fine. Please try this solution if you are using shortcut to run your sts.

Related

Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program

I've created a Play Framework program via Typesafe Activator (so it follows the template exactly).
I used sbteclipse-plugin version 3.0.0 to create an Eclipse project and imported that into Scala IDE 4.0.0. These are all the latest versions at the time of writing.
The Scala IDE definitely seems to support the Play Framework. It has syntax highlighting for the custom formats, including the routing file and templates. Yet, it doesn't seem to be able to find the views from the controllers. In particular, the call to views.html.index triggers an error: "object index is not a member of package views.html".
I tried enabling refreshing using native hooks or pooling as detailed here, but it had no affect.
I should note that while the code has been compiled in the command line (with activator ~run), it hasn't been compiled in Scala IDE, since I don't know how to (it doesn't seem to be documented anywhere).
What can I do to get rid of these false errors?
EDIT: After running activator clean ~run, I have another error: The project cannot be built until build path errors are resolved. There's no further details on what these build path errors are.
Update: Just upgrade to sbteclipse version 5.1.0 and everything should work out of the box. Also make sure you follow the Play documentation on how to set up Eclipse/ScalaIDE.
This is a known bug in sbteclipse, which probably will be fixed soon.
For now, you can add the following line to your build.sbt:
EclipseKeys.createSrc := EclipseCreateSrc.All
Kill the SBT console and run sbt eclipse again. That should add the following line to the .classpath file within your project folder as a workaround:
<classpathentry kind="src" path="target/scala-2.11/twirl/main"/>
Refresh your Eclipse project to pick up the change.
I had the same issue, also with Scala IDE 4.0.0 . I followed mkurz instuctions and they worked like a charm. But instead of changing the .classpath file in the project folder manually I used Eclipse interface:
In the top menu of the main window, click on Project and then on Properties.
In the Properties window, click on Java Build Path option (options list is on the left)
In the Source tab, click on Add Folder... button.
In the Source Folder Selection window, choose the target/scala-2.11/twirl/main folder, so it is included in the compilation path. Click Ok button.
Click Ok in the Properties window.
Now the project should compile just fine :) . With that I was able to finish the play setup example in Scala IDE website
I tried #mkurz solution first, but also ran into the same error as #matt. I became frustrated that I could not generate the eclipse project without having to go to the Eclipse project properties to manually fix the build errors. After some investigation, I discovered the solution that removed all errors entirely. Add this your build.sbt:
unmanagedSourceDirectories in Compile <+= twirlCompileTemplates.target
Or if that does not work for you, you could also use:
unmanagedSourceDirectories in Compile <+= target.zipWith(scalaBinaryVersion) { (b,v) => b / s"scala-$v/twirl/main" }
Good bye, build errors!
I got the same error message.
Are you using java8 as jre in eclipse?
After switching back from java8 to java7, everything worked fine again.
If, after following Mkurz' instructions (adding EclipseKeys.CreateSrc... ), your problems are not solved, click on Project -> Properties -> Java Build Path. Look at the source folders tab.
You may find a duplicate file folder named .../src_managed/main (Thanks Matt). If so, close the project. Remove ONE of the two ../src_managed/main entries from the .classpath file (located in the base of the activator/SBT project directory). Reopen and clean the project and you should be good to go.
For me, it turned out that installed JRE in the Scala IDE was openjdk, changed it to Oracle Java 8 and it worked.

Eclipse bug: This project has the JPA facet, but no JPA project could be created

After restarting Eclipse, I get the following error in my project:
This project has the JPA facet, but no JPA project could be created. See the error log for more details.
Nothing I've done (clean project, maven update, etc) will get rid of the error. My JPA Content icon remains greyed out.
It looks like this was a resolved bug at Eclipse bugs...but then why am I still getting it? Should I submit a bug report to Eclipse?
This is a configuration problem of the project. To solve this problem go to the project properties, and in the node "project facets" unchecked JPA and apply the changes. Now you can checked JPA and apply again!
For me all the above didnt worked.
So I tried Project Properties>Validate. It solved my problem.
To get rid of this error in Eclipse Luna, I just did a right-click on the project and chose the "Validate" menu item.
Alt+Enter in the project
Go for Project facets
Uncheck JPA and accept
Right click in the project, go for Validate
Alt+Enter in the project
Go for Project facets
Check JPA` and accept
Although this is an old thread, will try to give info that might just help someone.
I assume you have imported a project and it is giving this error.
Step 1 : Check under project properties if jpa is configured.
Step 2 : I have used eclipseLink as the user library for jpa. If you are using eclipse as well, try installing the plugin.
Step 3 : Check the version of jpa under project properties-> project facets... check for any conflicts in version, usually seen for java version and or any supporting libs. You should be able to change the version from facets.
JPA installation and configuration JPA installation and config
Step 4 : once JPA is configured for the project, clean and check. This should work.
I had the same problem and resolved it by installing both apt and jdt connectors for m2e.
Go to Window > Preferences > Maven > Discovery > Open Catalog. Look for m2e-apt and m2e-jdt-compiler. Install and then restart eclipse.
Click right button on your project-->properties-->validation-->uncheck JPA Validation .
That works for me!
Looks like the problem is in some cases caused by a missing JPA implementation in the classpath. After I added a Maven (test scope) dependency, the Eclipse error message disappeared:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
<scope>test</scope>
</dependency>
I this special case I had a "war" project that has a "persistence.xml" but no JPA code itself. The JPA stuff is in the referenced libraries (JARs).
For me, it was enough to clean the project.
Trying to disable JPA in the facet window caused an Exception.
Like kaushikjain said, validate your project and the error will disappear. This worked like a charm to me.
Right click in your project and Validate.
If you do not want to use JPA,
simply restart your eclipse and clean the project.
I had same problem when I copied JPA Entity to non-JPA project.
It worked for me and I hope it does so for yours :)

In PlayN, how can I upgrade to PlayN version 1.3.1 without getting "no lwjgl in java.library.path" error?

Update
The reason I couldn't update properly was I didn't have game's jar file properly installed. That was fixed by first running this on the command line:
mvn install:install-file -DgroupId=com.mygame -DartifactId=mygame-core -Dversion=0.9-beta -Dpackaging=jar -Dfile=/home/klenwell/projects/mygame/playn/mygame/java/target/mygame-java-0.9-beta.jar
Then, in Eclipse, I right-clicked java folder > Maven > Test. This updated all my dependencies including lwjgl.
Otherwise, see thomasbroad's answer.
Original Question
I've consulted the following authorities on this topic and applied their various recommendations:
http://lwjgl.org/installation.php
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Maven
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Eclipse
https://stackoverflow.com/a/11065814/1093087
https://groups.google.com/forum/?fromgroups#!topic/playn/E2t7gNh4ab0
https://groups.google.com/d/msg/playn/3D4JZ1Dbm-E/HmPHofS2fqgJ
Part of the problem is I'm not sure whether I should be following the Maven instructions or the Eclipse instructions. I've tried both and everything in between.
I'm working in Ubuntu 12.04 64-bit on Eclipse using Maven. Everything was working fine until I changed the PlayN version in my POM file from 1.2 to 1.3.1 and introduced the lwjgl dependency.
What I would have expected to have worked:
1) Download lwjgl (latest version 2.8.4) and test per lwjgl.org instructions (this was successful)
2) Update the appropriate POM files
2A) Add lwjgl.version as a property to mygame/pom.xml
<properties>
<playn.version>1.3.1</playn.version>
<lwjgl.version>2.8.4</lwjgl.version>
</properties>
2B) Add lwjgl as a dependency to mygame/mygame-java/pom.xml
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
3) Right-click mygame-java project in Eclipse > Run As > Run Configurations > Arguments and add either -Djava.library.path=target/natives or -Djava.library.path=/absolute/path/to/my/lwjgl/lib to VM arguments. (I've tried both variations.)
I can see the dependencies listed under my java project folder in Eclipse. And when I follow the lwjgl.org guide for Eclipse, I can see the jar listed under the java project folder. But I still get the error.
After two hours of hair-wrenching frustration, I hope somebody can either point out my fatal oversight or provide explicit instructions that will help me get back to work. Thanks.
I upgraded my project from 1.2 to 1.3 a while ago. I only updated my pom.xml files to refer to the new version of PlayN . I did not manually install lwjgl and neither did I add the lwjgl dependency as that one is implicitly pulled in by PlayN
Manually apply the diffs found here to your project, to your poms.
The key part being the piece in the java pom that tells Maven to unpack native dependencies. This part was actually added in the previous diff, so you may want to look there as well.
Now your IDE will most likely tell you that your project is not up-to-date with your poms, update your project, this should pull in the lwjgl dependency and set it up correctly.
I believe you should add the -Djava.library.path arguments to the VM Arguments, not to the Program Arguments in your runtime configuration.
The other -using maven- option is described on the Getting Started page, it worth noting, that the default embedded Maven is buggy for development, you should download and use at least Maven 3.0.3 as it is mentioned on the page (but I guess you already do this).
I just started a new project fresh with PlayN 1.4 and encountered this issue again in Eclipse. Resolved it as follows:
Right click mygame-java > Run As > Run Configurations...
Then added the following to VM Arguments under Arguments tab:
-Djava.library.path=target/natives
Then successfully ran as application.
At one point, I also ran the mvn install:install-file... command mentioned in question but I'm not sure whether that was necessary or not.

I have build errors with m2eclipse but not with maven2 on the command line - is my m2eclipse misconfigured?

I installed m2eclipse to build a java project in Eclipse.
I imported the project as follows:
Import->
Maven->
Existing Maven Projects->
Import Maven Projects->
- Select root directory
- Select pom file
- Click Finish
To be sure m2eclipse was actually building the project, I deleted the target directory and made sure it was re-created by m2eclipse and it was. But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.
Is it possible that I did not configure m2eclipse properly? How would I check this?
This is a github link to the project I'm trying to build. I'm getting the #Override build errors at this line. It says "The method createNewToken must override a superclass method".
Update: The problem is the same as the one described in ‘Must Override a Superclass Method’ Errors after importing a project into Eclipse and here is what the accepted answer says:
Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with #Override, but in Java 1.5 can only be applied to methods overriding a superclass method).
Changing the compiler level to Java 1.6 would make the problem go away. To do so, modify the compiler plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
And update the project configuration (right-click on the project then Maven V Update Project Configuration) does solve the problem under Eclipse.
Or stick with 1.5 but remove the problematic #Override annotations.
I don't know how Taylor got things working with a Java 1.5 compiler level. And my guess is that the project wouldn't build on the command line with a JDK 5.
But unlike with the command-line version of maven which built everything perfectly, m2eclipse leaves a large number of build errors in the source code.
Hard to say what is happening exactly without seeing those "errors" (are them really errors?). Please provide some traces.
Is it possible that I did not configure m2eclipse properly? How would I check this?
One difference is that m2eclipse uses by default a embedded version of Maven 3 which is probably not the same version that you use on the command line. You can change that through Window V Preferences V Maven V Installation (and add your own installation):
But while I would recommend to use the same version under Eclipse than on the command line, this is very likely not the root cause of the problem, Maven 2 builds should run on Maven 3 without problems.
I checked out the code. I have exactly the same problem. The code seems to be just broken.
Edit: It definitely is. Look at the class com.jappstart.service.auth.UserDetailsServiceImpl. It wants to override the method public final UserDetails loadUserByUsername(final String username) but this method doesn't exist in the interface the class implements and is has no superclass.
Edit: Ok, that doesn't explain why it builds with maven standalone. This also works for me. Very strange. It seems that there is something going on with the build that doesn't work with m2eclipse.
Edit: I'm pretty sure the code works because the bytecode is modified by the datanucleus plugin. When I run the project as maven build (right-click->Run->maven package) it sucessfully creates the war with m2eclipse. So my guess is that the problem is with the m2eclipse Maven Builder.
The override errors will appear if eclipse is configured to use java 1.5 instead of 1.6. Check the project properties.

Eclipse Galileo - JUnit missing

Build Path > Add Library > JUnit unable to add JUnit3 or JUnit4 components.
I see such message in the .log
!MESSAGE No property tester contributes a property projectPersistentProperty org.eclipse.team.core.repository to type class org.eclipse.core.internal.resources.Project
Eclipse Galileo installed by root user on Linux.
It works well for root and for other users except this JUnit issue.
Why it lost Junit?
(I've checked file permissions twice - all readable!)
This seems to be related to bug 239715, triggered by TypeExtensionManager.java, and due to some kind of plugins combination.
Could you check if your org.eclipse.core.expressions/.options file has the line
org.eclipse.core.expressions/debug/TypeExtensionManager=false
This should be enough to make that error message disappear.
That file is <eclipse-SDK-3.5-win32>\eclipse\plugins\org.eclipse.core.expressions_3.4.100.v20090429-1800.jar, and I just checked, it does contains the right option value (with latest Galileo) (are you using an older Galileo RC or Milestone release?).
Ah, I was getting this problem this morning. A search showed that it was possibly related to JGit/Egit. After updating the EGit plugin from 0.5 to 0.6, the errors have not returned.
You can make a variable junit or smtg similar to your customized one, add the junit folder to this varible, and give extension of it as junit4.8.1.jar.
I tried this and it works, but you have to delete any plugins of junit of version4 if present from plugins folder.