Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Controller not finding domain class

  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

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

    Default

    So you have other domain classes that you can scaffold fine? If so, that would indicate issues with the domain class definition. Perhaps its name. Try a different class name, such as ProgType. If that doesn't work, try adding this line to your logging configuration:

    Code:
    debug  'org.codehaus.groovy.grails.orm.hibernate'
    You'll have to remove that package from the 'error' or 'warn' line at the same time.

  8. #8
    Join Date
    Nov 2010
    Posts
    18

    Default

    I changed the name of the domain and controller to 'ProgType' and got the same error.

    Can you tell me where the logging configuration file is?

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

    Default

    grails-app/conf/Config.groovy - you'll find a line starting 'log4j = {' which is where the logging configuration is.

  10. #10
    Join Date
    Nov 2010
    Posts
    18

    Default

    Thanks!

    I've got the Config.groovy logging code set and I've restarted the app. The debug spit out a ton of stuff but I don't see anything that mentions 'ProgramType'.

    What do I need to look for in the debug log?

Posting Permissions

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