Announcement Announcement Module
Collapse
No announcement yet.
unable to resolve class myclass Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • unable to resolve class myclass

    Hi guys,
    i need your help.

    I just worked through the grails guide and now I am here: http://grails.org/doc/2.0.x/guide/GORM.html#basicCRUD

    The problem is, when i start the console Groovy Console pops up everything fine, but when I tried to create something with using the save method

    Code:
    def p = new Person(name: "Fred", age: 40, lastVisit: new Date())
    p.save()
    this error appears:
    Code:
    groovy> def p = new Person(name: "Fred", age: 40, lastVisit: new Date()) 
    groovy> p.save() 
     
    1 compilation error:
    
    unable to resolve class Person 
     at line: 1, column: 9
    well, this is my class Person, it is in -> C:\helloworld\grails-app\domain\helloworld :

    Code:
    package helloworld
    
    class Person {
    	String name
        Integer age
        Date lastVisit
    	
        static constraints = {
        }
    }
    What am i doing wrong? I read hear, that i should copy it direct to C: that there are no whitespaces -> http://groovy.codehaus.org/Class+Loading but it doesn't work.
    I also tried to import helloworld.Person in the BootStrap.groovy, but it also didn't work.

    Greetings
    Last edited by lolocaust; Mar 6th, 2012, 10:19 AM.

  • #2
    You need to import the class just like in any code:

    Code:
    import helloworld.Person
    
    def p = new Person(name: "Fred", age: 40, lastVisit: new Date())
    p.save()

    Comment

    Working...
    X