Error Scaffolding View Resolver - Grails

Today, while building a sample Grails application using the scaffolding approach, I encountered a new type of error, when running my Grails application. I had four domain classes and created a controller for each one of them. After the modelling of domain classes were complete, I added the following line of code inside my controller file to follow the scaffolding approach.
def scaffold = true
After this was done, when I executed the following command
grails run-app
I got the following exception on the screen;
C:\mygrails\demoapp>grails run-app
Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\mygrails\grails

Base Directory: C:\mygrails\demoapp
Resolving dependencies...
Dependencies resolved in 989ms.
Running script C:\mygrails\grails\scripts\RunApp.groovy
Environment set to development
  [groovyc] Compiling 5 source files to C:\mygrails\demoapp\target\classes
mcat
Running Grails application..
Server running. Browse to http://localhost:8080/demoapp

2011-06-27 13:41:29,282 [http-8080-2] ERROR view.ScaffoldingViewResolver  - Error generating scaffolded view [/postDetails/index]: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
java.io.FileNotFoundException: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.(FileInputStream.java:120)
        at java.lang.Thread.run(Thread.java:662)
2011-06-27 13:41:34,669 [http-8080-2] ERROR view.ScaffoldingViewResolver  - Error generating scaffolded view [/postDetails/index]: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
java.io.FileNotFoundException: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.(FileInputStream.java:120)
        at java.lang.Thread.run(Thread.java:662)
2011-06-27 13:41:37,797 [http-8080-2] ERROR view.ScaffoldingViewResolver  - Error generating scaffolded view [/profileDetails/index]: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
java.io.FileNotFoundException: C:\mygrails\grails\src\grails\templates\scaffolding\index.gsp (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.(FileInputStream.java:120)
        at java.lang.Thread.run(Thread.java:662)
After searching on this error in Google across multiple posts, I found that the cause of the error was the presence of the following additional line in each of my controller files
def index = { }
I removed this line from all the controller files and then retried running the demo grails application and it worked like a charm. If you have a similar ScaffoldingViewResolver issue for your Grails application, you can try this option out to see if it works for you.

1 comment:

  1. Thanks! I tried that with just one of the controllers, and it didn't seem to fix it, so I figured I'd taken the wrong route. It did work once I'd removed them all. Much appreciated.

    ReplyDelete