Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Controller not finding domain class

  1. #11
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Something like this:

    <pre>

    2011-08-09 16:12:16,442 [Thread-10] DEBUG cfg.GrailsAnnotationConfiguration - [GrailsAnnotationConfiguration] [1] Grails domain classes to bind to persistence runtime
    2011-08-09 16:12:16,456 [Thread-10] DEBUG cfg.GrailsAnnotationConfiguration - [GrailsAnnotationConfiguration] Binding persistent class [org.example.ProgramType]
    2011-08-09 16:12:16,457 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] Mapping Grails domain class: org.example.ProgramType -> program_type
    2011-08-09 16:12:16,479 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] bound property [id] to column name [id] in table [program_type]
    2011-08-09 16:12:16,486 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] bound property [version] to column name [version] in table [program_type]
    2011-08-09 16:12:16,488 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] Binding persistent property [description]
    2011-08-09 16:12:16,491 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] Binding property [description] as SimpleValue
    2011-08-09 16:12:16,491 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] bound property [description] to column name [description] in table [program_type]
    2011-08-09 16:12:16,491 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] Binding persistent property [name]
    2011-08-09 16:12:16,492 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] Binding property [name] as SimpleValue
    2011-08-09 16:12:16,492 [Thread-10] DEBUG cfg.GrailsDomainBinder - [GrailsDomainBinder] bound property [name] to column name [name] in table [program_type]
    2011-08-09 16:12:16,720 [Thread-10] INFO hibernate.ConfigurableLocalSessionFactoryBean - Building new Hibernate SessionFactory
    2011-08-09 16:12:16,720 [Thread-10] DEBUG cfg.GrailsAnnotationConfiguration - [GrailsAnnotationConfiguration] Setting context class loader to Grails GroovyClassLoader
    2011-08-09 16:12:17,160 [Thread-10] INFO hibernate.GrailsHibernateTransactionManager - Using DataSource [org.springframework.jdbc.datasource.TransactionAwa reDataSourceProxy@1806e9d2] of Hibernate SessionFactory for HibernateTransactionManager
    </pre>

  2. #12
    Join Date
    Nov 2010
    Posts
    18

    Default

    I'm seeing lines like that for all of my other domain classes but nothing for 'ProgramType'. It almost seems like hibernate isn't seeing it at all.

  3. #13
    Join Date
    Nov 2010
    Posts
    18

    Default

    I've changed the code in my controller 3 times. Each time I get a different error message.

    If I use this line to get the scaffolding:
    Code:
    static scaffold = ProgramType
    I get this error:

    2011-08-09 16:22:58,570 [Thread-58] ERROR plugins.DefaultGrailsPlugin - Cannot generate controller logic for scaffolded class class com.xfitlog.ProgramType. It is not a domain class!
    If I use this code:

    Code:
    def scaffold = true
    I get this error:

    2011-08-09 16:20:53,602 [Thread-33] ERROR plugins.DefaultGrailsPlugin - Cannot generate controller logic for scaffolded class true. It is not a domain class!
    2011-08-09 16:21:18,211 [http-8080-1] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /xfitlog/programType/scaffold
    Stacktrace follows:
    java.lang.ClassCastException: java.lang.Boolean cannot be cast to groovy.lang.Closure
    at java.lang.Thread.run(Thread.java:619)
    and if I use the code generated by the generate all command I get this error:

    2011-08-09 16:25:28,272 [http-8080-5] ERROR errors.GrailsExceptionResolver - Exception occurred when processing request: [GET] /xfitlog/programType/list
    Stacktrace follows:
    groovy.lang.MissingMethodException: No signature of method: static com.xfitlog.ProgramType.list() is applicable for argument types: (org.codehaus.groovy.grails.web.servlet.mvc.Grails ParameterMap) valu
    es: [[action:list, controllerrogramType, max:10]]
    Possible solutions: is(java.lang.Object), wait(), wait(long), print(java.io.PrintWriter), split(groovy.lang.Closure), use([Ljava.lang.Object
    at com.xfitlog.ProgramTypeController$_closure2.doCall (ProgramTypeController.groovy:31)
    at com.xfitlog.ProgramTypeController$_closure2.doCall (ProgramTypeController.groovy)
    at java.lang.Thread.run(Thread.java:619)

  4. #14
    Join Date
    Jun 2010
    Location
    London
    Posts
    304

    Default

    Have you tried removing your 'target' directory and possibly recreating the ProgramType domain class? All the above errors mean the same thing: Grails is not seeing ProgramType as a domain class. Is there no difference between it and the other domain classes?

  5. #15
    Join Date
    Nov 2010
    Posts
    18

    Default

    I removed the 'target' directory and rebuilt the project. Resulted in the same error.

    I tried to create a more complex domain object before 'ProgramType'. That is when I first noticed the error. I created 'ProgramType' as a very simple object to try and isolate the problem.

    I'm beginning to wonder If I screwed the project up by introducing a MySQL DB connection in the test environment. Here is my DataSource.groovy code. Let me know if anything looks amiss.

    Code:
    dataSource {
        pooled = true
        driverClassName = "org.hsqldb.jdbcDriver"
        username = "sa"
        password = ""
    }
    hibernate {
        cache.use_second_level_cache = true
        cache.use_query_cache = true
        cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
    }
    // environment specific settings
    environments {
        development {
            dataSource {
                dbCreate = "update" // one of 'create', 'create-drop','update'
                url = "jdbc:hsqldb:file:devDb;shutdown=true"
            }
        }
        test {
            dataSource {
    			pooled = true
    			driverClassName = "com.mysql.jdbc.Driver"
    			url = "jdbc:mysql://localhost/public" //"jdbc:mysql://localhost/xfitlog"
    			dbCreate = "update"
    			username = "sa"
    			password = ""
    			dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            }
        }
        production {
            dataSource {
                dbCreate = "update"
    			url = "jdbc:hsqldb:file:prodDb;shutdown=true"
    			// AWS RDS
                //url = "jdbc:mysql://ironworkslog.cat4owdsmbkz.us-east-1.rds.amazonaws.com:3306/ironworkslog"
    			//Instance: IronWorksLog
    			//UserName: ironworks_user
    			//Password: xfitLogBitch
            }
        }
    }
    Thanks for your continued help!!

  6. #16
    Join Date
    Nov 2010
    Posts
    18

    Default

    Okay. I ran a little experiment. I had a test project on the same machine. I added a 'ProgramType' domain object and controller to that project and set 'def scaffold = true'. Everything worked fine.

    This tells me that there is definitely something wrong with the 'xfitlog' project. Now all I have to do is figure out what that problem is!

Posting Permissions

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