Spring roo project doesn't compile in eclipse - eclipse

I have to maintain a spring roo project so I imported it in eclipse, I can build it, if I run roo command
"perform eclipse"
it works.
The problem is that eclipse show compilation errors like :
The method entityManager() is undefined for the type MyType
or when trying to get model property :
mytype.getName();
The method getName() is undefined for the type MyType
I can see in the file MyType_Roo_JavaBean.aj that the method exits :
privileged aspect MyType_Roo_JavaBean {
...
public String MyType.getName() {
return this.name;
}
...
}
I am using eclipse Juno + roo 1.2.2 + Spring framework 3.1.0 + m2e plugin + STS plugin (nightly build).
I installed STS pluging hoping, it would help, but there is the same error with or without it.
Do you have an idea of what can be wrong ?
thanks !

Try to use the complete STS Version 2.9.x instead of a self assembled eclipse, because it looks like your eclipse is missing AspectJ. If you use the complete STS (Not only the spring plugin) you should have everything you need.
Another hint is to run in eclipse: project / maven / “Update project configuration"

I am using Spring Tool Suite 3.4.0.RELEASE, and ran into a problem similar to this.
Problem: There are numerous warnings and errors occurring through out my class.
Solution: Double check that you don't have any malformed methods anywhere in the class. Anything appears to cause this. Some possible causes could be missing (1) semi-colon (2) closing brackets, and/or (3) closing braces. In my case, I had made some changes to an Enum being used, and I forgot to check where it was being used. Once you get that cleaned up, you should be fine (or, at least I was).

What you need is an AJDT Configurator which also needs AJDT to be installed first.
So, if you don't have AJDT installed in your eclipse (Juno).. first install it from :
http://download.eclipse.org/tools/ajdt/42/update
Then, you need to install AJDT Configuarator from :
http://dist.springsource.org/release/AJDT/configurator/
Well, this thing worked for me, with the same configuration. Lemme know, if this helps you..

Related

No Dependency Injection and missing EclispeContext in Plugin

I have written an eclipse product, based on Eclipse Neon, which contains a self written plugin. Now I changed the platform to Eclipse 2019-06. Since then I get an InjectionException at the integratetd plugin.
I've debugged the code and found out, that the injection of this Plugin doesn't work any more and the EclipseContext is always null. I also tried to create the Objects with the #Creatable Annotation.
Do I have to transport the context from one plugin to another? In my opinion this isn't necessesary. So, had someone else this problem and has solved it?

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:
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.

Spring Data Graph and Eclipse

Spent 2 days trying to understand how to enable Eclipse work with Spring Data Graph, have no idea yet. The code is like this:
#NodeEntity
public class Person {
public Person() {
}
}
...
public class App {
public static void main(String[] args) {
Person p = new Person().persist();
}
}
This code is absolutely fine, when I build it with Maven. When I open the project in Eclipse, it says that there's no method persist() in class Person.
I'm using Eclipse 3.7 (on Ubuntu 11.04), Spring 3.0.6.BUILD-SNAPSHOT, AspectJ 1.6.12.BUILD-SNAPSHOT, Spring Data Graph 1.2.0.BUILD-SNAPSHOT. I also have AJDT 2.2.0.e37x-20110815-2000 installed.
My Eclipse project is AspectJ-enabled (I have AJ on project's icon).
I'm wondering if anyone could tell me what are the exact versions of all these tools I need to install in order to get rid of errors in Eclipse.
Please, comment if these details are not enough.
Update:
Also posted this question to official Spring Data Graph forums:
http://forum.springsource.org/showthread.php?113629-Using-Spring-Data-Graph-in-real
no feedback so far.
It is used in real projects, no worries.
The problem you've encountered with the tooling is a sad part of the story.
We didn't anticipate that many issues with AJ in eclipse with the AJDT plugin developed by the AspectJ guys.
There is a second thread in the forum and a JIRA issue, in which the AJDT project lead concluded the following:
Make sure the Project Properties -> AspectJ -> Aspect Paths are set correctly
Make sure Window->Preferences->JDT Weaving in turned ON.
The build path "*/.aj" is NOT needed - I dont have it and it works fine.
A project build is required each time eclipse starts
Obsolete: See Michal Hunger's answer
I ran into the same problems, what did the trick for me was fixing the Java build path, as described here (the note) http://static.springsource.org/spring-data/data-graph/docs/current/reference/multi/programming-model.html
After that I had to clean and rebuild the project.
Hope that helps.
From the AJDT website:
AJDT configurator for m2e v1.0 is now available at http://dist.springsource.org/release/AJDT/configurator/. Add this update site to your Eclipse install manager to install the configurator. This configurator will ensure that Maven projects in Eclipse are properly configured with AspectJ and AJDT.
posted 09-30-11
I've installed the above and my AspectJ build path now has spring-aspects and spring-data-neo4j added, with the comment 'From: Maven Dependencies'. (As a side note: libs added to the AspectJ build path are also added to the Java build path).
However, I don't yet understand what the configurator does exactly or what is needed in the POM to 'activate' it, as the configurator properly adjusted (the AspectJ build path of) the cineasts project, but not my project based on the hello-world example. Can somebody shed some light on this?
Edit: Looks like the configuratior takes the aspectLibraries configuration option from the aspectj-maven-plugin (if found in the POM) and adds it to the aspectj build path of the project.
Looks like we're getting closer to a good integration :-)
(Sorry for posting another answer, not much option with my reputation atm).

Groovy/Grails - Unable to Resolve Class

I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder as well as others like Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService
. I have Grails 1.3.7 selected in the Project Properties, but I don't see an item for 'Grails Depedencies' like I do when I create a sample project. Is this the problem? How can I add it back in?
I don't know why, but here are the steps I took to solve the problem:
Right click on the project and go to Grails Tools -> Enable Dependency Management
Grails Tools -> Refresh Dependencies. This correctly added the 'Grails Dependencies' library.
I still had plugin errors. I for some reason had to uninstall them and then reinstall them for the project to realize they were there.
For anyone who is using Grails >= 2.4
If you are using Grails 2.4 and above, use grails.util.Holders instead of org.codehaus.groovy.grails.commons.ConfigurationHolder.
Read the doc here section 'Static Holder'
Classes The following deprecated classes have been
removed from Grails 2.4.x:
org.codehaus.groovy.grails.commons.ApplicationHolder
org.codehaus.groovy.grails.commons.ConfigurationHolder
org.codehaus.groovy.grails.plugins.PluginManagerHolder
org.codehaus.groovy.grails.web.context.ServletContextHolder
org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder
If you or any plugins you have installed are using these classes you
will get a compilation error. The problem can be rectified by updating
to new plugins and using grails.util.Holders instead.
If "Refresh Dependencies" has done all it can for you (as you indicate in your comment on the question), try disabling and re-enabling dependencies. You might try refreshing dependencies again afterward if the Acegi plugin still isn't recognized.
there is another way solved me this issue when i moved my workspace from Windows OS to Ubuntu , go to
yourWorkSpace -->yourGrailsProject-->setting folder --> org.grails.ide.eclipse.core.prefs,
then check all the grails paths are correct or not , because in my case all were pointing to windows paths ..
Hope this solve.
I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.

How to use Scala in IntelliJ IDEA (or: why is it so difficult to get a working IDE for Scala)?

I recently gave up trying to use Scala in Eclipse (basic stuff like completion doesn't work). So now I'm trying IntelliJ. I'm not getting very far.
I've been able to edit programs (within syntax highlighting and completion... yay!). But I'm unable to run even the simplest "Hello World". This was the original error:
Scala signature Predef has wrong version
Expected 5.0
found: 4.1 in .... scala-library.jar
But that was yesterday with IDEA 9.0.1. See below...
UPDATE
Today I uninstalled IntelliJ 9.0.1, and installed 9.0.2 Early Availability, with the 4/14 stable version of the Scala plug-in.
Then I setup a project from scratch through the wizards:
new project from scratch
JDK is 1.6.u20
accept the default (project) instead of global / module
accept the download of Scala 2.8.0beta1 into project's lib folder
Created a new class:
object hello {
def main(args: Array[String]) {
println("hello: " + args);
}
}
For my efforts, I now have a brand-new error :)
Here it is:
Scalac internal error: class java.lang.ClassNotFoundException [java.net.URLClassLoader$1.run(URLClassLoader.java:202), java.security.AccessController.doPrivileged(Native Method), java.net.URLClassLoader.findClass(URLClassLoader.java:190), java.lang.ClassLoader.loadClass(ClassLoader.java:307), sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301), java.lang.ClassLoader.loadClass(ClassLoader.java:248), java.lang.Class.forName0(Native Method), java.lang.Class.forName(Class.java:169), org.jetbrains.plugins.scala.compiler.rt.ScalacRunner.main(ScalacRunner.java:72)]
FINAL UPDATE
I uninstalled 9.0.2 EA and reinstalled 9.0.1, but this time went with the 2.7.3 version of Scala rather than the default 2.7.6, because 2.7.3 is the one shown in the screen-shots at the IntelliJ website (I guess the screen-shots prove that they actually tested this version!). Now everything works!!!
I have encountered the same scalac error when trying to run a Scala project in Intellij Idea 9.0.2 and I've managed to find a solution by chance :). These are the steps I took in creating the project and running it.
I have created a Scala project in Intellij Idea 9.0.2 final (it was released today). I have installed the Scala plugin, restarted the IDE and created a new Scala project (with the name "TestScala") with scala-2.8.0.Beta1 as project library. Once the project is created and the scala libraries downloaded, I have created a Test.scala file with the following content:
object Test {
def main(args:Array[String]){
println("hello")
}
}
After that, I created a launch configuration ("Edit Configurations"), choosing the "Application" template. I set as main class Test and choose the project name ("TestScala") in the "Use classpath and JDK of module" combo box. When I run the configuration I get the same error as you reported ("Scalac internal error: class java.lang.ClassNotFoundException") .
Now comes the freaky part :). I right click on the project, choose "Module Settings", have a look on all settings but I don't change anything . Click "apply" and "ok", try to run configuration again and it works :) .
I use Intellij Idea 9.0.2 the final release (build 95-66); Ubuntu 9.10 and JDK 1.6.0_18. I also have to mention that I had a JDK configured in Intellij, otherwise there is an extra step to configure it.
UPDATE:
When checking the setting of the module, one needs to click on the Module->Scala and Facets->Scala (expand it and click on Scala(ProjectName)) . Both of these settings are about the scala compiler and scala library location. I would guess these values are not properly set when the project is created but are saved once the user touches them and saves the settings.
To answer your question, it's difficult to get a working IDE for Scala for two reasons:
(a) Scala is only just beginning to reach a wide audience and
(b) due to (a), there is no business case for spending time on a Scala IDE.
Also, if you are old enough to cast your mind back and young enough to still remember, you would know that for the first five or more years of Java, we were stuck with okay-ish tools like JBuilder that did little more than compile your code when you said so - no error highlighting, no auto-importing, and the word refactoring didn't even exist. If you want to pioneer, you need to be prepared to cut some of the road yourself, or at least bush-bash.
I know it won't help you, but I have successfully used IDEA for Scala on Linux, Mac and Windows. I typically have the Scala SDK installed somewhere locally and point IDEA at that rather than using the 'download' option.
Presently, I am mostly using an EAP version of IDEA 9 on Mac OS X with Scala 2.8.0.Beta1-RC5 and it's working well (except that fsc doesn't seem to worked with mixed sources).
You could try your luck over at the IDEA Scala Plugin Discussion Forum, though I haven't had a great lot of responses to my own postings there.
Installing the plug-in is prerequisite one.
The next thing you should do is define a library (global or project-specific; I use global) that holds the Scala library and compiler JAR files (at a minimum, that's scala-compiler.jar and scala-library.jar). Adding source JARs and a documentation JAR or URLs is a good idea, too. Then make this library a dependency of any modules in your project that include Scala code.
Lastly, find the Scala facets in those modules and de-select both check-boxes there.
I just did a fresh install and had exactly this same problem myself.
It turned out that, because I had created the file in the root package, IDEA had added a package statement at the top with naming a package. I assume that this then got compiled as "package object Main" - valid syntax in 2.8? Anyway, I deleted the line that said package and it all worked fine.
I had the same problem yesterday while trying to set it up. Solution is pretty simple, you just have to set scala somewhere in project settings.
You are mixing code compiled with two different Scala versions.
I use Netbeans to write scala programs. So far it works very well with my codes. You can try the plugin here: http://wiki.netbeans.org/Scala68v1.
I was getting this error and also had to right click on the project and "Open Module Settings". However, it was more than just hitting apply. I had to make sure that my Content Root was correct for each project. For some reason, there were some incorrect Source and Test Folders.
My project uses maven as the main build tool and importing the project into Intellij is probably what created these incorrect settings.
I had similar problem, following this blog post instructions solved the problem for me