Hey all- I'm working on some web flows for a Grails app we're building. I'm (slowly) getting the hang of the webflows themselves, but progress is severely limited due to the fact that changes to the webflow controller are not auto-reloading in Tomcat on save; basically, I need to bounce the app every time I make a change. As you can imagine, this is pretty painful. I think auto-reload was working a couple of days ago and then stopped, but I'm not sure.
Has anyone else experienced this? Any thoughts on how to make auto-reload work?
Thanks!
After much trial and error, here's what I found:
Situation: I have a controller with a single webflow. The first stage of the webflow uses a command object. (Grails 1.3.1)
1) Command and Webflow in same file; Command first: everything works, but the controller will not auto-reload on save.
2) Command and Webflow in same file; Webflow first: doesn't work- a serialization exception thrown when trying to render the page that references the command object.
3) Command and Webdlow in different files: everything works and controller auto-reloads.
For now I'll just keep everything in separate files. If anyone has insight into why this behavior is being exhibited, I'm all ears.
Related
I'm looking to introduce the Grails DBMigrations plugin into an existing application.
My understanding is that after installation the first thing to do is to create the initial changelog.groovy which I've done with the command
dbm-generate-gorm-changelog changelog.groovy
This does create the file correctly, and contains all the necessary commands to recreate the database schema.
Secondly my understanding is I should then issue the command dbm-changelog-sync to indicate that the changelog script has been executed.
What should happen if I then issue the command dbm-gorm-diff ?
At this point I'm expecting to see an empty changelist... because the initial schema was created, committed and no changes have been made to any domains, however I see a bunch of entries.. for modifying column types and a few index creation entries.
Any advice appreciated, I've reached this point because I want to update the database in a production env database, and don't want to start writing manual tests and SQL in bootstrap to update the DB as this will surely lead ultimately to a maintenance migraine. Using DBMigrations appears to be the way forward but either I don't understand it, or it's buggy and don't want to risk using it.
And as others have commented in other threads, I'm restarting the grails console between issuing commands to avoid reloading problems.
Thanks
Dave,
The important thing to remember about the migrations plugin is that is output from dbm-gorm-diff is not meant to be taken as gospel. It is simply meant as a way to hopefully save you from some typing. Anything generated automatically from the plugin should be reviewed and analyzed to determine that it is what you desire.
Not sure if I could reliably reproduce this, but sometimes when I switch branches in development all requests start throwing an undefined method error inside of a helper. The method is present on both branches. I am using global helpers (helper :all).
To fix the issue, I go into the helper file and save any change. Usually I just add a new line to the end of it. After saving, it works fine. Seems like a caching issue.
Has anyone else seen this and resolved it? I am on Rails 4.2.1. As far as I know this only happens in development mode.
Since you are using Rails 4.2, spring has probably cached the code from the old branch. After switching to the new branch remember to run:
spring stop
Spring will restart itself the next time you run the server, tests, or other Rails commands.
I am using Grails 2.3.5 with database migration plugin in new project for understand how it is working. But sometimes dbm-gorm-diff provide empty changelog file,even changes is there.
For example,
i have the person domain class with out any properties.
When initially creating change log, it will create 2 fields id and version in change log.
After that, added 2fields name,age into that person class. then did dbm-update and dbm-gorm-diff that give like following.
databaseChangeLog = {
}
Sometimes gives the changes. some times is not working. Please help me. Why it is working like that. Sorry for bad english.
Using the following tutorial works for me. Make sure you remove dbCreate from your DataSource.groovy. According to the tutorial the workflow is as follows:
Setup
Remove dbCreate from DataSource.groovy
Initially run grails dbm-generate-gorm-changelog changelog.groovy
Sync the changelog with your db by running grails dbm-changelog-sync
Changing domain
Change domain class
Run grails dbm-gorm-diff <your-filename>.groovy --add
Run grails dbm-changelog-sync
Hope this helps
I have spent some time searching for the answer to this same issue.
Caveat: I am using the Grails interactive shell to issue commands, including the dbm-* commands.
By brute force alone, I have come to the conclusion that the domain classes are not reliably reloading. To get consistent results (especially with the generation of new changeLog files), any time I modify a domain class, I stop and restart the Grails interactive shell before calling dbm-gorm-diff. I've tried issuing other commands like clean, compile, package and refresh-dependencies and they just aren't working, and the -reloading flag at the start up of the Grails interactive shell doesn't seem to make any difference either.
Restarting the Grails interactive shell, however, does seem to work reliably, thought it galls me to do so :)
Those who do not use the interactive shell should not be having this problem since the domain classes are loaded with every command call.
This blog has detailed step by step explanation, specially Migrating old databases section helped us in migrating successfully.
My project has always used grails 2.0.1 and my controllers define their actions as methods not closures. Previously these actions have always worked (i.e. the browser can render the correct gsp page first going through the action method in the controller).
Recently we've noticed that the bespoke actions no longer work, the browser reports a '404 resource not found'. We're still on grails 2.0.1, this is confirmed by 'loading grails 2.0.1' comments in every grails command that is run. Although there are some controller/domain/services changes, none of those changes should affect the use of action methods. From what I can tell, we've not downgrade the version of grails/groovy.
If I change the actions to be defined as closures, then it works fine. But I'm not happy with this as my solution as methods are the preferred way and it used to work.
I've tried the usual approach to grails weirdness: proper clean and rebuild, but no joy. Also, this is an issue in both eclipse and unix envs (project delivered as a war run by the grails command), so it must be something in the project files but I cannot spot anything that has changed.
Any suggestions what could have happened to my project and how to resolve?
I've finally tracked my problem down to an aspect I was using to monitor long running method calls. I had changed the pointcut to include 'within(com.mydomain.domain..*)' which is where my Controller class resides. This appeared to stop my bespoke links from working, not entiring sure why. I hadn't intended this, I just wanted my pointcut to include all domain class methods but I'm happy to sacrifice that in order to get controller method actions working again.
I've resolved this issue by amending my pointcut.
I'm brand new to ruby on rails and trying to run an application developed by others. I downloaded it from SVN it running yesterday, but today when I try to run it the first attempt to access the site's home page I get the message:
expected .../app/helpers/interface/table_helper.rb to define Interface::tableHelper.
.../lib/active_support/dependencies.rb:452:in 'load_missing_constant'
This file exists, and properly defines the tableHelper interface. Since I was able to run the program when I was setting it up yesterday, and others can run it without issue, I assume the problem I'm seeing is caused by an incorrectly set up environment rather then bad code somehow.
Can anyone suggest what I might try to figure out why rails can't seem to detect a properly defined interface?
If you were able to run the program once, perhaps something got screwed up? Have you made any changes to the code?
Alternatively, try stopping and restarting the server.
Also: what's the application? Maybe we can look at the codebase...