Debug grails recompilation - grails

I am working on grails 2.0.4 project and at some point I've found that recompilation process does not work. Further tries showed that first run-app after removing ~/.grails/2.0.4 has recompiling process working well, but running run-app next time ignores changes in files during run (no changes on pages and no Compiling… message in log after appears). So my question is how to debug recompilation process?

There's some JIRA issues related to the recompilation:
http://jira.grails.org/browse/GRAILS-8951
http://jira.grails.org/browse/GRAILS-8573
http://jira.grails.org/browse/GRAILS-8914
Only the third one is fixed. Looking in the first, some folks said that this not work:
grails run-app
But entering in the interactive mode works:
grails
run-app
Looking a bit in the code, I can see that GrailsProjectWatcher.java is responsible for file changes. Try to add debug to the related package and see if you get messages.

If it's one particular class that's not reloading, one thing you can check is that the package definition is correct. Grails will happily compile a class that is in the wrong package, but this breaks the reloading mechanism.

Related

Why does my Windows Service built with .net 6.0 and Host.CreateDefaultBuilder fails at startup with DI errors?

I've spent too long on this not to share.
I made a Windows Service with .Net 6.0 and the Host.CreateDefaultBuilder method. It worked fine, was deployed correctly. Then I modified something that worked in dev, but failed at startup in prod.
Looking at the logs, there was a problem with Dependency Injection that pointed back to the first line of my Program.cs. I tried everything around every DI thing I injected in the code, all the way to doing an "empty service" that was running a Task.Delay loop with nothing injected at all. It still failed.
I went back with working versions stored in Git. Still failed.
Nothing changed on the server, afaik.
So ultimately, I figured out that the problem was in the bundling of the Publish process: when using publish as single file, it failed. Turning that feature off solved it.
So in your .csproj, add (or modify) this line:
<PublishSingleFile>false</PublishSingleFile>
I don't know why it worked at some point and stopped working, but there's definitely something not right with that process.

Grails / IntelliJ: trouble with simple groovy import?

I'm following Burt Beckwith's (Grails developer and author) use of Heroku as indicated here in Grails book. (See import statement at top of this link -- that's what's giving me problems).
I added the following to BuildConfig.groovy as Burt indicates:
runtime 'postgresql:postgresql:8.4-702.jdbc3' // in the dependencies section as described
compile ':heroku:1.0.1' // in the plugins section as described.
Then IntelliJ prompted me to update the IDE with the BuildConfig changes, which I did. I also exited and restarted IntelliJ to see if that might get rid of the import error for:
import grails.plugin.heroku.PostgresqlServiceInfo
It did not get rid of the import error, which then complains when I do the addition of:
PostgresqlServiceInfo info = new PostgresqlServiceInfo()
in the Bootstrap class as is shown in the example. What am I doing wrong / how do I fix this kind of stuff?
In IDEA you need to open Tools | Grails | Plugins, select Heroku plug-in and click Apply Changes.
This will configure a module for the plug-ins and add this module to the dependencies of your application.
Take some time.
Halt the idea of using IDEA for a moment.
Use command prompt.
Try the same steps.
You will see everything working.
Works for me. :-)

Grails Project Not Auto Reloading

I have a larger Grails project for which I have taken over development. I have used Grails before and one of the features that I found really nice-to-have is the auto-compilation/reloading when developing.
I haven't had to do anything special to make this work in the past, however for some reason it is not triggered for this project.
I do a simple "grails run-app" and modify a file when server is started - nothing! Any suggestions?
Windows 7, Grails 2.0.1, Java 1.6u35
IDE: Groovy Grails Tool Suite 3.1.0.M1 - Based on Eclipse Juno 4.2
Grails command line doesn't seem to properly handle spaces in directory names of GRAILS_HOME or HOME directory.
see:
http://jira.grails.org/browse/GRAILS-7936
it has links to various other related issues.
This comment has a workaround: http://jira.grails.org/browse/GRAILS-7936?focusedCommentId=72170&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-72170 .
Are you using eventCompileStart in scripts/_Events.groovy? That was my problem, see GRAILS-8776 (please comment and vote on that issue if this is your problem so we can get it resolved!).
Commenting out that block cause auto-reloading to start working again for me.
My solution:
Right click on project -> Properties -> Project Facets -> check Java and set it's correct version -> OK
Bingo!

Grails and IntelliJ Cache Issues

we are using Grails together with Maven and Intellij. For the beginning of the project it worked everything nicely. Now we are getting more and more strange effects like when somebody is checking in wrong code, some are getting error some are not.
Are there any best practices to config IntelliJ so thats it working on each machine good and predictable?
We found out that some having the "make" before starting the project disabled but this didnt solved the issue.
Thanks for your help!
Got very little problems in 2 years. Idea had couple of cache issues a year ago, I wiped caches by hand. Ever since then, had no problems with caches/indexes.
Couple of things I could think of:
grails clean usually fixes most weirdness;
Yes, removing "Before launch - make" flag stops Idea from doing wrong guesses and unnecessary compilation (which id does differently from Groovy compiler);
For every new run configuration, we add ValueFormatter to VM parameters, or add it to Grails defaults;
Create a run configuration for test-app and run it on regular basis;
Give it as much memory as you can in idea.vmoptions.

Grails & Netbeans: making changes without rerunning run-app

Hey all,
I'm just starting with Grails in Netbeans (6.9.1). I got a demo working, but each time i change a groovy file i need to build the project, and then select run (ie the equivalent of "grails build" and "grails run-app"). If there is already an instance running, I need to first shut that instance down.
This seems wrong. It seems like i should be able to just change the groovy file, and it would get automagically reloaded. Isn't that the point of groovy?
Is this actually how it's supposed to work in Netbeans? Without getting into an IDE war, do other IDEs do it better? everyone seems to rave about the Grails support in IntelliJ. Is it worth it?
One last point... I noticed that a regular war maven project no longer automatically reloads on an F11 build. Could this be related?
Thanks
--Matthias
Do not expect to have reloading for all your files even by running your grails app through command line.
Depending on which groovy file you have changed, grails run-time auto-reloading will work or not. Indeed:
Files and folders supporting reloading in development mode: gsp files (in view folder), grails services (in service folder), controllers, taglibs, css, i18 resources, javascript files, some config files (like Config.groovy), url mappings. Note that there are some Grails bug when for instance, using spring transactional annotation in Services makes the reloading crashed
Files and folders NOT supporting reloading (and requiring a restart of the application): any code under src/groovy, src/java, Domain classes (under domain directory), some configuration files, changes in plugins, any code under utils folder (if you have any Codec for instance)
So in your case, if you change a controller groovy file AND NetBeans restarts the application, I recommend you to use a separate command line for running grails application and using the IDE for code changes. The only bad side is that you will not use the NetBeans debugger.
Actually this is the way I work with Grails and IntelliJ

Resources