Generate scaffolding with Grails - 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.

Related

Grails 2.4.0.RC1: NullPointer when executing list-plugin-updates

When I execute
grails list-plugin-updates --stacktrace
I receive the following error:
| Environment set to development....
| Error Error executing script ListPluginUpdates: java.lang.NullPointerException: Cannot get property 'plugin' on null object (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException: Cannot get property 'plugin' on null object
at ListPluginUpdates$_run_closure1_closure5_closure6.doCall(ListPluginUpdates.groovy:28)
at ListPluginUpdates$_run_closure1_closure5_closure6.doCall(ListPluginUpdates.groovy)
at ListPluginUpdates$_run_closure1_closure5.doCall(ListPluginUpdates.groovy:27)
at ListPluginUpdates$_run_closure2_closure9.doCall(ListPluginUpdates.groovy:67)
at ListPluginUpdates$_run_closure2.doCall(ListPluginUpdates.groovy:66)
at ListPluginUpdates$_run_closure1.doCall(ListPluginUpdates.groovy:26)
at ListPluginUpdates$_run_closure1.doCall(ListPluginUpdates.groovy)
at ListPluginUpdates$_run_closure4.doCall(ListPluginUpdates.groovy:85)
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.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 executing script ListPluginUpdates: java.lang.NullPointerException: Cannot get property 'plugin' on null object
Can anyone tell me what I am doing wrong?
Facing this exact issue. You can vote for it up to prioritize.
There were similar issues raised as well for 2.3-M1 and 2.0-RC2 but they seem to be fixed. I think this popped up again for newer versions.

Compile error trying to use Grails' Quartz plugin

I am trying to install and use Grails' Quartz plugin. My grails' version is 2.3.7
I added compile ":quartz:1.0.1" to my Build.config;
and downloaded quartz-2.2.1.jar and quartz-jobs-2.2.1.jar; and then added these .jar files to my /lib folder.
When I try grails run-app, the following error appears:
Compile error during compilation with javac.
C:\Users\username\Documents\NetBeansProjects\Siscoserv-web\target\work\plugins\quartz-1.0-RC11\src\java\grails\plugins\quartz\CustomTriggerFactoryBean.java:51: error: inconvertible types
if(customTrigger instanceof AbstractTrigger){
^
required: AbstractTrigger
found: Trigger
C:\Users\username\Documents\NetBeansProjects\Siscoserv-web\target\work\plugins\quartz-1.0-RC11\src\java\grails\plugins\quartz\CustomTriggerFactoryBean.java:52: error: inconvertible types
AbstractTrigger at =(AbstractTrigger) customTrigger;
^
required: AbstractTrigger
found: Trigger
C:\Users\username\Documents\NetBeansProjects\Siscoserv-web\target\work\plugins\quartz-1.0-RC11\src\java\grails\plugins\quartz\CustomTriggerFactoryBean.java:56: error: no suitable method found for setJobKey(Key)
at.setJobKey(jobDetail.getKey());
^
method AbstractTrigger.setJobKey(JobKey) is not applicable
(actual argument Key cannot be converted to JobKey by method invocation conversion)
method MutableTrigger.setJobKey(JobKey) is not applicable
(actual argument Key cannot be converted to JobKey by method invocation conversion)
When I tried to install the plugin and run Grails, the following error appeared during run-app:
|Compiling 216 source files
.Error
|
Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.IncompatibleClassChangeError: Implementing class (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.IncompatibleClassChangeError: Implementing class
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.codehaus.gant.GantBuilder.invokeMethod(GantBuilder.java:99)
at _GrailsCompile_groovy$_run_closure3_closure8_closure9.doCall(_GrailsCompile_groovy:61)
at _GrailsCompile_groovy$_run_closure3_closure8_closure9.doCall(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at _GrailsCompile_groovy.withCompilationErrorHandling(_GrailsCompile_groovy:68)
at _GrailsCompile_groovy.this$4$withCompilationErrorHandling(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:168)
at _GrailsCompile_groovy$_run_closure3_closure8.doCall(_GrailsCompile_groovy:60)
at _GrailsCompile_groovy$_run_closure3_closure8.doCall(_GrailsCompile_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsCompile_groovy$_run_closure3.doCall(_GrailsCompile_groovy:57)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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 _GrailsCompile_groovy$_run_closure2.doCall(_GrailsCompile_groovy:44)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:168)
at _GrailsPackage_groovy$_run_closure2_closure8.doCall(_GrailsPackage_groovy:42)
at _GrailsPackage_groovy$_run_closure2_closure8.doCall(_GrailsPackage_groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:41)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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 RunApp$_run_closure1.doCall(RunApp.groovy:28)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
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.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
at gant.Gant.executeTargets(Gant.groovy:590)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1254)
Error |
Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.IncompatibleClassChangeError: Implementing class
I didn't erase the class's name in the error above, it just doesn't appear.
I found out what the problem was:
It seems shiro has quartz as a dependency, and it was downloading a different version than the one the quartz plugin uses.
I fixed it adding the following excludes statement to my Build.config.
compile (":shiro:1.2.0") {
excludes([name: 'quartz', group: 'org.opensymphony.quartz'])
}
I found out the problem by creating a new project and enabling the quartz plugin, and then the others using some kind of binary search, until I found the problem.
If you have installed the plugin as
compile ":quartz:1.0.1"
version 1.0.1, then why are you getting errors from quartz-1.0-RC11. From stacktrace:
C:\Users\username\Documents\NetBeansProjects\Siscoserv-web\target\work\plugins\
quartz-1.0-RC11\src\java\grails\plugins\quartz\CustomTriggerFactoryBean.java:51:
error: inconvertible types
Delete the traget directory, delete the old version of quartz from local .m2 (local maven repo), delete other reference (like in .grails\app\..), if any, from the app and then run grails clean && grails compile, it should be good.
I do not see any problem with the plugin getting compiled with a grails app built on 2.3.7.
Remove the JAR files from your lib directory. You do not need them there. The plugin will provide all the required JARs. This is one of the benefits of the plugin system for Grails. Adding these JARs to your lib directory is causing conflicts.

grails 2.3 spock integration test No WebApplicationContext found error

I just upgraded an existing App from Grails 2.2.4 to 2.3.0. All spock Integration tests are broken since then. The error message I got is shown below. There is no problem running unit test or run-app. Thanks advance for any advice.
| Error Fatal error running tests: No WebApplicationContext found: no ContextLoaderListener registered? (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered?
at org.springframework.web.context.support.WebApplicationContextUtils.getRequiredWebApplicationContext(WebApplicationContextUtils.java:90)
at grails.util.Holders.getApplicationContext(Holders.java:78)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:95)
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.invokeMethod(GantMetaClass.java:133)
at TestApp$_run_closure1.doCall(TestApp.groovy:32)
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.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 Fatal error running tests: No WebApplicationContext found: no ContextLoaderListener registered?
You no longer need to add the Spock plugin to your projects for grails >= 2.3.
Simply create Spock specifications as before and they will be run as unit tests. In fact, don't install the Spock plugin, otherwise your specifications will run twice and potentially fail. This also means that the spock test type no longer exists.
Specifications and JUnit tests run as the same type now.
OK. I figured this out a while ago.
The reason is I tried to mock servletcontext in the integration test while it is already provided for in Grails 2.3.2. After removing the mocked servletContext, everything worked lie before.

Where to put #Grab annotation in Grails Service

I have the following groovy code ,and i excute it on grails console plugin . it works fine .
However, i want to reuse it in grails' service.
#Grab( 'net.sourceforge.nekohtml:nekohtml:1.9.18' )
import org.cyberneko.html.parsers.SAXParser
def html = '''<p>
| I wanted to try to <span id="blk1">match</span> the inner part
| of the string<span id="blk2"> between </span> the span tags <span>where</span>
|</p>'''.stripMargin()
def content = new XmlSlurper( new SAXParser() ).parseText( html )
List<String> spans = content.'**'.findAll { it.name() == 'SPAN' && it.#id?.text()?.startsWith( 'blk' ) }*.text()
ATTEMPT1:
import groovy.grape.Grape;
#Grab( 'net.sourceforge.nekohtml:nekohtml:1.9.18' )
class MyService {
//..
}
ERR :
*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message can't create byte arrau at ../../../src/share/instrument/JPLISAgent.c line: 793
i tried to put #Grab annotation before method that shall do the code above, i have an error.
i tries to put #Grab before class ,the same result; it's an error also .
Where do i put #Grab annotation .
ATTEMPT2:
When i add the dependency above in BuildConfig.groovy ,
runtime( 'net.sourceforge.nekohtml:nekohtml:1.9.18')
ERR :
i get the following error :
grails> --stacktrace -Dserver.port=9090 run-app
| Packaging Grails application.....
| Error Error running script --stacktrace -Dserver.port=9090 run-app: org/apache/xerces/dom/DeferredElementNSImpl (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NoClassDefFoundError: org/apache/xerces/dom/DeferredElementNSImpl
at org.apache.xerces.dom.DeferredDocumentImpl.getNodeObject(Unknown Source)
at org.apache.xerces.dom.DeferredDocumentImpl.synchronizeChildren(Unknown Source)
at org.apache.xerces.dom.CoreDocumentImpl.getDocumentElement(Unknown Source)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at _GrailsPackage_groovy$_run_closure5.doCall(_GrailsPackage_groovy:74)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:58)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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 RunApp$_run_closure1.doCall(RunApp.groovy:30)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
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$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:1243)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
at gant.Gant.executeTargets(Gant.groovy:590)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243)
| Error Error running script --stacktrace -Dserver.port=9090 run-app: org/apache/xerces/dom/DeferredElementNSImpl
ATTEMPT3:
Likewise,adding the dependency in BuildConfig.groovy did not solve the problem.
dependencies {
//....
// .......
compile( 'net.sourceforge.nekohtml:nekohtml:1.9.18'){
excludes 'xercesImpl'
}
}
Reference: http://www.grailsforum.co.uk/showthread.php/2143-New-to-grails-problem-with-JAVA-jar-dependencies#post_message_2323
Even i use the solution above, it works only when compiling.
ATTEMPT4:
I execute the following command to add the dependency ; but in vain :
grails install-dependency net.sourceforge.nekohtml:nekohtml:1.9.18 --dir=lib
ERR
And i get , this error message :
Packaging Grails application.....
| Error Error running script run-app: org/apache/xerces/dom/DeferredElementNSImpl (Use --stacktrace to see the full trace)
Best practices to Put all libraries either :
in lib folder then Refersh , or in
or
in conf/BuildConfig.groovy
Hiowever , if you want to use Grape , Use the following syntax:
import groovy.grape.Grape
Grape.grab(group:'net.sourceforge.nekohtml', module:'nekohtml', version:'1.9.18')
or
groovy.grape.Grape.initGrape()
#Grab(group='net.sourceforge.nekohtml', module='nekohtml', version='1.9.18')
public class MyService{
}

Grails db-migration plugin

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/

Resources