Grails db-migration plugin - grails

I'm trying to change my database model, so I followed this tutorial. Btw I'm using Grails 1.3.7.
I ran:
grails install-plugin database-migration
It installed fine!
But when I ran:
dbm-generate-gorm-changelog changelog.groovy
It gave me the following error:
java.io.FileNotFoundException: grails-app\migrations\changelog.groovy (The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
at java.io.FileWriter.<init>(FileWriter.java:90)
at _DatabaseMigrationCommon_groovy$_run_closure7.doCall(_DatabaseMigrationCommon_groovy:128)
at _DatabaseMigrationCommon_groovy$_run_closure7.call(_DatabaseMigrationCommon_groovy)
at DbmGenerateGormChangelog$_run_closure1_closure2.doCall(DbmGenerateGormChangelog:28)
at DbmGenerateGormChangelog$_run_closure1_closure2.doCall(DbmGenerateGormChangelog)
at _DatabaseMigrationCommon_groovy$_run_closure6_closure18.doCall(_DatabaseMigrationCommon_groovy:88)
at _DatabaseMigrationCommon_groovy$_run_closure6_closure18.doCall(_DatabaseMigrationCommon_groovy)
at grails.plugin.databasemigration.MigrationUtils.executeInSession(MigrationUtils.groovy:99)
at grails.plugin.databasemigration.MigrationUtils$executeInSession.call(Unknown Source)
at _DatabaseMigrationCommon_groovy$_run_closure6.doCall(_DatabaseMigrationCommon_groovy:81)
at _DatabaseMigrationCommon_groovy$_run_closure6.call(_DatabaseMigrationCommon_groovy)
at DbmGenerateGormChangelog$_run_closure1.doCall(DbmGenerateGormChangelog:27)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)

you may be missing a "--add":
dbm-generate-gorm-changelog --add changelog.groovy
An excellent entry point to database-migration for grails (by grails' team): http://blog.springsource.org/2011/08/17/countdown-to-grails-2-0-database-migrations/

Related

grails fail generated war (assets)

i have a strange error when i generate war with grails war commande
| Processing File 53 of 1214 - yuiApplication/dial/assets/dial-core.css.
| Error WAR packaging error: /Users/sovlin/IdeaProjects/revelido/grails-app/assets/javascripts/yuiApplication/dial/assets (Is a directory)
I don't understand why this folder make problem. I check it but nothing of suspect.
I test clean-clean without success.
The run-app commande working.
Error with StackTrace
war --stacktrace | Processing File 53 of 1214 -
yuiApplication/dial/assets/dial-core.css. | Error WAR packaging error:
/Users/sovlin/IdeaProjects/revelido/grails-app/assets/javascripts/yuiApplication/dial/assets
(Is a directory) | Error Error running script war --stacktrace:
org.codehaus.groovy.grails.cli.ScriptExitException (NOTE: Stack trace
has been filtered. Use --verbose to see entire trace.)
org.codehaus.groovy.grails.cli.ScriptExitException
at _GrailsWar$_run_closure2.doCall(_GrailsWar.groovy:43)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.codehaus.gant.GantMetaClass.processClosure(GantMetaClass.java:81)
at org.codehaus.gant.GantMetaClass.processArgument(GantMetaClass.java:95)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:128)
at War$_run_closure1.doCall(War.groovy:38)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
at gant.Gant$this$2$withBuildListeners$0.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at gant.Gant.executeTargets(Gant.groovy:590) | Error Error running script war --stacktrace:
org.codehaus.groovy.grails.cli.ScriptExitException
Here my plugin configuration
asset-pipeline 2.0.17 -- Asset Pipeline Plugin
cache 1.1.8 -- Cache Plugin
database-migration 1.4.0 -- Grails Database Migration Plugin
hibernate4 4.3.6.1 -- Hibernate 4 for Grails
jquery 1.11.1 -- jQuery for Grails
scaffolding 2.1.2 -- Grails Scaffolding Plugin
spring-security-core2.0-RC4 -- Spring Security Core Plugin
tomcat 8.0.15 -- Apache Tomcat plugin
webxml 1.4.1 -- WebXmlConfig
Thanks you for your help
It definitely has to do with a folder that is named as if it was a file that needs processing. Asset-Pipeline however should be correcting for this and I have modded core to ensure a check and make sure File is not a Directory. This is released in 2.0.18

Generate scaffolding with Grails

I'm new in Grails and I get an issue when I try to generate my controllers and views using the scaffolding...
Before generate the scaffolding I just create an empty app using "grails create-app myapp".
Command :
grails generate-all Book
Errors :
| No domain class found for name Book. Please try again and enter a valid domain class name
| Error Error running generate-all
| Error Error running script generate-all --stacktrace Book: org.codehaus.groovy.grails.cli.ScriptExitException (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.codehaus.groovy.grails.cli.ScriptExitException
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at GenerateAll$_run_closure1.doCall(GenerateAll.groovy:47)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
at gant.Gant.executeTargets(Gant.groovy:590)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1259)
| Error Error running script generate-all --stacktrace Book: org.codehaus.groovy.grails.cli.ScriptExitException
The correct way is to include package while writing your domain class name
grails generate-all package.Book
Also make sure domain class is already created before calling this command.
Thanks.
I have the similar problem, but your problem is caused because you aren't specifying the route of the class domain.

Grails compile error

I'm getting the following error in my Grails app. Grails 1.3.7, Spring Security plugin 2.6 How to solve this? I can still run the app but this is realy bugging me.
Configuring Spring Security UI ...
2011-12-08 09:35:07,701 [main] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [springSecurityCore:1.2.6]: You must provide a configuration attribute
java.lang.IllegalArgumentException: You must provide a configuration attribute
at SpringSecurityCoreGrailsPlugin$_closure3.doCall(SpringSecurityCoreGrailsPlugin.groovy:538)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:263)
at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy)
at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:299)
at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy)
at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:245)
at RunApp$_run_closure1.doCall(RunApp:35)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Server running. Browse to http://localhost:8080/Test2
I'm on 1.2.4, but the plugin code in SpringSecurityCoreGrailsPlugin.groovy:538 is referencing the filterChain in your securityConfig (which should now be in your Config.groovy file - unlike the Acegi plugin). As suggested look in the plugin source code. You'll find it in: ~/.grails/1.3.7/projects/{yourproject}/plugins
This plugin is an awesome, if somewhat complicated beast - get the basics down with the tutorial: Spring Security Plugin Tutorial Then read the docs carefully, it will save you a ton of time.

Compilation error with Grails 1.3.7 and springcache plugin 1.2.1

I am trying to compile a Grails project using Grails 1.3.7 . The project has a dependency to springcache 1.2.1 plugin. However, I get the following compilation error (29 times):
/Users/myself/.grails/1.3.7/projects/myproject/plugins/springcache-1.2.1/src/groovy/grails/plugin/springcache/web/Timer.groovy: 29: cannot modify final field 'uri' outside of constructor.
# line 29, column 4.
this.uri = uri
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:969)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:519)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:453)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:67)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:180)
at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:905)
at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:607)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at _GrailsCompile_groovy$_run_closure4_closure10.doCall(_GrailsCompile_groovy:117)
at _GrailsCompile_groovy$_run_closure4_closure10.doCall(_GrailsCompile_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsCompile_groovy$_run_closure4.doCall(_GrailsCompile_groovy:104)
at _GrailsCompile_groovy$_run_closure3.doCall(_GrailsCompile_groovy:69)
at _GrailsPackage_groovy$_run_closure2_closure9.doCall(_GrailsPackage_groovy:85)
at _GrailsPackage_groovy$_run_closure2_closure9.doCall(_GrailsPackage_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:84)
at RunApp$_run_closure1.doCall(RunApp.groovy:28)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
According to the stacktrace, my project is perfectly innocent ;-)
I tried to use springcache 1.3.1 instead but then I run into the problem that another third-party plugin also requires version 1.2.1 . Is there a way to use two different versions for the same build?
Grails does not allow installing two versions of the same plugin within a project.

Grails error executing create-app

I am using jdk1.6 and grails 1.3.4. I have set the JAVA_HOME,GRAILS_HOME and PATH variables following the instructions in the grails.org site. When I execute the create-app command I get the following error:
C:\grails\grails-1.3.4>grails create-app C:\Users\Documents\Grails\helloworld
Welcome to Grails 1.3.4 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\grails\grails-1.3.4
Base Directory: C:\grails\grails-1.3.4
Resolving dependencies...
Dependencies resolved in 2102ms.
Running script C:\grails\grails-1.3.4\scripts\CreateApp_.groovy
Environment set to development
Error executing script CreateApp: java.lang.StringIndexOutOfBoundsException: Str
ing index out of range: 1
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:
1
at java.lang.String.substring(String.java:1934)
at grails.util.GrailsNameUtils.getClassNameRepresentation(GrailsNameUtil
s.java:82)
at grails.util.GrailsNameUtils$getClassNameRepresentation.call(Unknown S
ource)
at _GrailsCreateProject_groovy$_run_closure4.doCall(_GrailsCreateProject
_groovy:135)
at _GrailsCreateProject_groovy$_run_closure1.doCall(_GrailsCreateProject
_groovy:36)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
... 10 more
--- Nested Exception ---
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.substring(String.java:1934)
at grails.util.GrailsNameUtils.getClassNameRepresentation(GrailsNameUtil
s.java:82)
at grails.util.GrailsNameUtils$getClassNameRepresentation.call(Unknown S
ource)
at _GrailsCreateProject_groovy$_run_closure4.doCall(_GrailsCreateProject
_groovy:135)
at _GrailsCreateProject_groovy$_run_closure1.doCall(_GrailsCreateProject
_groovy:36)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Error executing script CreateApp: java.lang.StringIndexOutOfBoundsException: Str
ing index out of range: 1
There is a StringIndexOutOfBoundsException. Can anyone help me resolve this?
Thanks
SJan
create-app: The starting point for Grails. This command creates a Grails application and requires the user to specify the application name. A subdirectory within the directory the command was executed from is then created based on the entered application name.
The correct way to execute this command:
Browse to your workspace directory using the command prompt
Type "grails create-app helloworld
A subdirectory "helloworld" will be created as your workspace directory

Resources