Grails Project Not Compiling Automatically in STS Version 2.9.2 - java

I have a project which has couple of plugins. It has a fairly large amount of classes. The problem is when I tried to save the changes in my code (ie in a controller or gsp file), it doesnt automatically compile. The project by the way is running, but if I change something lets say in the controller or gsp file, it doesnt automatically compile and therefore the changes doesn't take effect. I have to stop the run process first and then run it again so that the changes will take effect. I just encounter this problem recently. I am using SpringSourceToolSuite Version: 2.9.2.RELEASE. I checked the Automatic Build option and it was turned on. Any idea why is this happening and how to solve it?

Related

How do I get Netbeans to use the specified Gradle version?

I've come back to project after a long diversion, and upgraded tooling. This means Netbeans 12.5, Java 17, Gradle 7.3… at least allegedly. For some reason, despite setting the Gradle version to 7.3, it appears to build with 7.0.
Per the image below, setting the Gradle version to 7.3 doesn't seem to be picked up. (That is immediately after hitting Apply.) It still tries to build with 7.0. And – for some indeterminate reason – it can't.
Restarts don't help; I can't get the configuration to be picked up. (Searches for reference to similar issues provide 5-year-old answers that are no longer relevant.) I've even tried deleting the 7.0 distribution; to no avail, it comes right back.
Can anyone provide guidance on getting this to work properly?
Netbeans 12.6 fully supports Java 17 and Gradle 7.3. Gonfiguring the Gradle wrapper for 7.3 gets picked up correctly, eliminating all errors I was experiencing.
Don't bother with gradle in Netbeans. It's a horrible, buggy disaster and 12.6 just seems to want to up the ante.
Netbeans does NOT support gradle in a meaningful way for normal users.
You now get complex multi-projects whether you want them or not.
When creating a Java Application you don't get a choice at what the Main class is called. It will be App with app.java and you will like it.
If you try to rename app.java to something useful. It will not change "Class App" to "Class Useful" it will instead change it to "ClassUsefulp". It will not rename the test file and you will be left with several syntax errors that you can have fun cleaning up.
No, you cannot rename the subproject itself. That will continue to be the extremely descriptive and useful "app" subproject. The IDE will not provide you a way to rename that.
There is no meaningful, intuitive way to create/delete/modify subprojects.
If your gradle version is somehow out of sync there is still no useful way to reset/recreate the gradle wrapper other than creating a whole new project and moving your source code over to the new project.
Oh, so you gave in and accepted the multi-project structure. You noticed that if you go through the multi-project creator GUI then you can create multiple subprojects. Yeah, good luck with that. They won't have gradle build.scripts or wrappers. You won't be able to build your awesome creation.
Want to use command line arguments? Forget it. There is no "run" element in the project properties. You cannot create different run configurations.
Want dependencies? Or any other project configuration? It's all manual editing of gradle files. There's no GUI to assist non-gradle-wizards.
Yeah. you can probably work around a lot of this by dropping to a command line shell and editing the gradle scripts/files manually and running gradle commands manually. A) you're going to need to be a gradle wizard, and B) why are you using an IDE in the first place? you've got gradle, you've got vi available. Bathe in the nostalgia because you'll have to anyways.
Do you like the idea of gradle? Do you use Netbeans? Stick with Ant, or Maven if you need external dependencies; you'll thank me later.

IntelliJ IDEA + Play Framework - how to speed up compilation

We just started using Play Framework 2 (Java) with IntelliJ IDEA (14.1.1) on a new project.
As it is now, simple tasks like running tests always seem to start with a 20 second long "make" step, and then the tests itself takes a few milliseconds.
According to the "messages" view, the Play 2.0 compiler is handling compilation, even though this is not checked in the Play2 options in IDEA.
Is this normal?
Are there any known quickfixes for how to make this work in a practical way?
A workaround was described in the issue mentioned in my last comment.
Disable play2 compiler in settings
Delete the play*xml files in the .idea folder for your project
Restart IDEA
If you reimport the project (e.g. when build.sbt changes), you'll have to delete the xml files and restart IDEA again.
This will presumably be fixed - look for updates in the YouTrack Issue

Java - AspectJ corrupted Eclipse?

I installed AJDT plugin from eclipse site. Then created Aspectj project. And if I saved anything in there, it started building workspace forever. I tried to close Eclipse, but needed to force close it and now it won't even starts, just loads forever. My code in project are only few lines, so I don't get it why it should be that slow. What could be wrong? Is AspectJ that slow or what?
How could I restore Eclipse as I can't even use it now..
Update
Eclipse loaded after like 10 minutes. Then I deleted one character of code and pressed save and it all started again. That is insane. I suppose it shouldn't be like that? I unchecked 'Build automatically' option, but it sill does the same thing.
And now I just got this error:
java.lang.OutOfMemoryError
Compile error: OutOfMemoryError thrown: GC overhead limit exceeded
So it just ran out of memory. So it is something really wrong, but I don't see what could be.
Also this only happens with AspectJ project, with normal project everything runs smoothly. So maybe I should do something in AspectJ project before trying to write there, like check/uncheck something?
P.S. I also added Spring jars and commons-logging jars in that project. Maybe that has something to do with it?

Java Play! Startup Problems

When I first ran eclipsify on my Project I noticed that Eclipse complained about the:
return ok(index.render("Your new application is ready."));
Line. It did not recognize the index method. The application still ran so I ignored it for the time being. Now, however, I am getting a new error. I think I just added a few dependencies to Mongo, attached some Model files and rebuilt but I am now getting this error:
compile: sbt.InvalidComponent: Could not find required component 'compiler-interface-src'
I'm not sure why this is happening, especially because I'm a bit of a sbt idiot. As a side note, Eclipse is reporting that my "classes_managed" build path entry is missing, but I think that is due to my inability to compile after doing a clean. (Clean and update are working).
1) Templates are compiled by Play, not by eclipse. After the "eclipsify", you need to run play compile (or play run) and refresh your eclipse project. See How to make Eclipse see the changes in Play! compiled templates?
2) After adding dependencies, launch a new time the play eclipsify command.
But i think it's not the problem. What is the dependency you add ? And what is your Play2 version? (I suspect an incompatibility with a Play2.1 library)
And for your information, a general rule: Play doesn't depend on Eclipse to compile files. Do not try to clean in eclipse, but run play clean (and refresh eclipse).
Happen to run into this issue few times, tried above, also following
Clean up Play-framework based project
But nothing worked.
What it turned out to be was a IntelliJ Idea cache corruption issue, and invalidate and restart Idea worked fine.

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file "name of class"

I know this question may seems stupid since i cannot give a lot of infos about it, but I think that the problem has to be some kind of bug...
I have written a java program whith NetBeans 7.1, which now gets me this error when trying to run. 10 mins ago it was perfectly running, and i have changed nothing to the class the error refers to
Could this be some kind of NetBeans error? Maybe it is a well know problem?
It also got this exception in NB 7.2
'clean an build' and restarting NB didn't work
updating NB with the latest updates and performing 'clean and build' also didn't work.
So i renamed the cache directory:
c:\Users\userabcd\AppData\Local\NetBeans\Cache\7.2\index\
started NB, waited for it to finish 'background scanning' and pressed 'Debug project' and voila. The cache gets corrupted every once in a while :-/
EDIT: Added Solution B below.
Solution A:
Project Properties
Build >> Compiling
un-check: Compile on Save
Clean and Build
Notes A:
If you leave Compile on Save un-checked, you won't have this problem any longer for this project.
If you enjoy the benefits of the Compile on Save feature, you can re-check the option after you clean and build, and continue work on your project as normal.
Compile on Save is meant to save time by constantly recompiling your .java files into .class files in the background as you save changes to your source code. That way when you build or run your project, most of the compiling work has already been completed allowing you to run and test your code quickly, even for large projects.
NetBeans uses some fancy caching and versioning to avoid having to recompile your entire project every time you save a file. That's why the other solutions listed here will often work; they are ways of defeating this caching-and-versioning system when it occasionally fails, as it has above.
Solution B:
Create empty folder e. g. C:\Temp\mine
Create a new shortcut for NetBeans
with command line parameter in Target:
"C:\Program Files\NetBeans 8.2\bin\netbeans64.exe" --userdir "C:\Temp\mine"
When compile errors occur
(ClassNotFoundException, MethodNotFoundException, etc...)
delete C:\Temp\mine\var\cache
Notes B:
You'll lose all your NetBeans settings the first time.
Much easier to solve future compile errors caused by caching bugs.
Allows running multiple copies of NetBeans, one per userdir.
I got also this exception. My solution was:
edit and save mentioned class (.java file)
clean & build project
deploy to tomcat server
I just had this happen to me with Netbeans 7.4 Beta.
Things I tried:
Restarting Netbeans.
Clean and build.
Shutting down netbeans, renaming the cache dir, starting netbeans and waiting for scanning to complete.
What worked for me:
Making the source file writable and saving a meaningless change (inserting a space).
I don't know why any of the other steps didn't fix the error. Maybe it would have worked if I had done a clean and build after renaming the cache dir?
Its a very frustrating situation to be in - Hopefully this helps someone (perhaps a future me?).
The JDK says for ClassFormatError:
Thrown when the Java Virtual Machine attempts to read a class file and
determines that the file is malformed or otherwise cannot be
interpreted as a class file.
Perhaps a class file has become corrupted. I am going to do the standard IT support statement.
Have you tried restarting NetBeans?
Hope that helps
Got right the same thing with Netbeans 7.1.
Working on a project that works fine for several months.
Now I changed a bean which gets persisted with javax.persistence and now this exception got thrown. Reverted my few changes, clean and compile the project, reboot the whole system: still exceptions.
The curious thing about it: the generated .war works perfectly in a Tomcat at another machine.
UPDATE:
Today I got the same problem again and I couldn't recall how to solve it, but I found this post again. ;)
After a half hour I found the solution: Just change value of the property serialVersionUID, redeploy the app and then you can change the value to its original value and redeploy again -> working.
Seems like Tomcat is holding that class somewhere deep inside – deleting working directories didn't led to success.

Categories