Results 1 to 10 of 16

Thread: Controller not finding domain class

Hybrid View

  1. #1
    Join Date
    Nov 2010
    Posts
    18

    Default Controller not finding domain class

    I have been attempting to add some new functionality to an existing grails application. I started by adding a simple domain class through the console:

    Code:
    package com.xfitlog
    
    class ProgramType {
    	String name
    	String description
    		
        static constraints = {
    		name( nullable: false, unique: true )
    		description( nullable: false )
        }
    	
    	String toString() {
    		"${name}"	
    	}
    }
    I then created a simple controller through the console:

    Code:
    package com.xfitlog
    
    class ProgramTypeController {
    
        static scaffold = ProgramType
    }
    When I execute grails run-app and navigate to the controller page I get this error:

    ERROR plugins.DefaultGrailsPlugin - Cannot generate controller logic for scaffolded class class com.xfitlog.ProgramType. It is not a domain class!

    Does anyone have any idea what could be causing this in an application that is already up and running?

  2. #2
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    When you say you added a simple domain class "through the console", what do you mean exactly? In other words, what were your exact steps? Were you in interactive mode?

  3. #3
    Join Date
    Nov 2010
    Posts
    18

    Default

    I first created the domain class using the grails create-domain-class command in the windows command prompt. I then opened up the .groovy file that was created and edited it. After that I created the controller through the windows command prompt with grails create-controller. I then opened up the controller file created and edited it.

  4. #4
    Join Date
    Nov 2010
    Posts
    18

    Default

    I've also noticed that the controller does not appear on the Available Controllers list after the project builds. If I make any change to the controller file then save it I will get the following error:

    [Thread-610] ERROR plugins.DefaultGrailsPlugin - Cannot generate controller logic for scaffolded class class com.xfitlog.ProgramType. It is not a domain class!

    I think that something has gone wrong with the grails files or hibernate, but I'm not sure where to start looking.

  5. #5
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    What version of Grails? Are you doing any of these steps from an IDE? How are you starting the application?

  6. #6
    Join Date
    Nov 2010
    Posts
    18

    Default

    I'm using version 1.3.7 and I haven't had any problems with it up until I tried to create this new domain class. All of these steps are through the Windows Command Prompt and Notepad++.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •