0
votes

As I'm starting with Grails I've started to create a small project. I wanted to integrate scaffolding so I could see and edit my domain fields.

But when I do 'run-app' I get the following error:

ERROR ScaffoldingGrailsPlugin - Cannot generate controller logic for scaffolded class true. It is not a domain class!

Although this allows the server to start up on my localhost but when trying to open my ProductType controller page I get a gsp error:

HTTP Status 404 - "/WEB-INF/grails-app/views/productType/index.gsp" not found.

So I figure the index.gsp page was not created since I haven't coded any gsp pages with that name.

The code for my test Model:

package grailstest

class ProductType {

    String productCode
    String productName
    String productDescr

    static constraints = {
        productCode (size: 3..20, unique: true, nullable: false)
        productName (maxSize: 45, blank: false)
        productDescr (maxSize: 500, blank: true)        
    }
}

And the code for my test Controller:

package grailTest

class ProductTypeController {
    static scaffold = true

    def index() { }
}

So it's as basic as you can get. Obviously it must be something very simple staring at me mocking me.

2
Remove def index() { } from the controller and run a grails refresh-dependencies before running the app. - dmahapatro

2 Answers

0
votes

A typo on the package name would generate this error.

Changing the controller package name from:

package grailTest

To:

package grailstest

That fixes the problem and the model and controller classes can see each other. Scaffolding is running now.

Duh!

0
votes

One of the following things need to be present:

  • Either package name & class name of controller should be in line with the Domain class

OR

  • Domain class should be specified explicitly

Example:

class AbcController {

    // Specify domain class
    static scaffold = Domain

}