NullPointer exception when scaffolding first Grails app

grails

Solution

I tried this and able to reproduce it. If we generate view then it is resolved but without views it is giving error. There is an issue in `grails` `jira`, see this issue they have provided a patch for it.

Hope this helps.

Problem

Starting out with Grails I have installed Grails version 2.4.0 and using JDK 1.7.0_55 on GNU/Linux I do the sequence of actions below but keep getting a NullPointerException. Can someone provide a pointer to what I am missing or doing wrong ? ``` grails create-app firstgrails cd firstgrails grails grails> run-app ``` I go to localhost:8080/firstgrails and see the generated page. Next I do ``` grails> create-domain-class tag ``` and go to the firstgrails/grails-app/domain/firstgrails folder and edit Tag.groovy so it contains: ``` // Tag.groovy package firstgrails class Tag { String name String description } ``` Next ``` grails> create-controller tag ``` and edit firstgrails/grailsapp/controllers/firstgrails/TagController.groovy into ``` // TagController.groovy package firstgrails class TagController { static scaffold = Tag } ``` I do a reload in the browser and firstgrails.TagController is added to the list of available controllers under the welcome message. Selecting it, I create a tag with name and description and the tag shows up in the list of tags as expected. But now whenever I try to add a second tag I get an 500 error: Internal Server Error with ``` URI: /firstgrails/tag/create Class: java.lang.NullPointerException Message: null ``` The trace in the console is: ``` Error 2014-06-03 18:28:31,714 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /firstgrails/tag/create Stacktrace follows: Message: Error processing GroovyPageView: Error executing tag <g:form>: Error executing tag <g:render>: null Line | Method ->> 527 | doFilter in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:form>: Error executing tag <g:render>: null ->> 35 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:render>: null ->> 30 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by NullPointerException: null ->> 333 | hash in java.util.concurrent.ConcurrentHashMap - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 988 | get in '' | 141 | getValue in grails.util.CacheEntry | 81 | getValue in '' | 73 | doCall . in tag_create$_run_closure2_closure24 | 78 | doCall in tag_create$_run_closure2 | 81 | run . . . in tag_create | 189 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread | Error 2014-06-03 18:30:33,050 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /firstgrails/tag/create Stacktrace follows: Message: Error processing GroovyPageView: Error executing tag <g:form>: Error executing tag <g:render>: null Line | Method ->> 527 | doFilter in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:form>: Error executing tag <g:render>: null ->> 35 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:render>: null ->> 30 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by NullPointerException: null ->> 333 | hash in java.util.concurrent.ConcurrentHashMap - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 988 | get in '' | 141 | getValue in grails.util.CacheEntry | 81 | getValue in '' | 73 | doCall . in tag_create$_run_closure2_closure24 | 78 | doCall in tag_create$_run_closure2 | 81 | run . . . in tag_create | 189 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread | Error 2014-06-03 18:32:21,796 [http-bio-8080-exec-5] ERROR errors.GrailsExceptionResolver - NullPointerException occurred when processing request: [GET] /firstgrails/tag/create Stacktrace follows: Message: Error processing GroovyPageView: Error executing tag <g:form>: Error executing tag <g:render>: null Line | Method ->> 527 | doFilter in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:form>: Error executing tag <g:render>: null ->> 35 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by GrailsTagException: Error executing tag <g:render>: null ->> 30 | doCall in /tag/create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Caused by NullPointerException: null ->> 333 | hash in java.util.concurrent.ConcurrentHashMap - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 988 | get in '' | 141 | getValue in grails.util.CacheEntry | 81 | getValue in '' | 73 | doCall . in tag_create$_run_closure2_closure24 | 78 | doCall in tag_create$_run_closure2 | 81 | run . . . in tag_create | 189 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter | 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread ```

Original source