Grails: generate-all Class Error: No domain class found for name “Class”

Categories: Development Notes; Tagged with: ; @ December 3rd, 2012 19:35

After I created a new Class using: 

grails> create-domain-class User

I want to to generate the controller:

grails>generate-all User

I got these error:

| No domain class found for name User. Please try again and enter a valid domain class name
| Error Error running generate-all (Use –stacktrace to see the full trace)
| Error Error running script generate-all User: org.codehaus.groovy.grails.cli.ScriptExitException (
Use –stacktrace to see the full trace)
grails> –stacktrace
| Error Error running script –stacktrace: Cannot invoke method findAll() on null object (NOTE: Stac
k trace has been filtered. Use –verbose to see entire trace.)
java.lang.NullPointerException: Cannot invoke method findAll() on null object
        at RunApp$_run_closure8_closure13.doCall(RunApp:229)
        at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.ja
va:1231)
        at RunApp$_run_closure8_closure13.doCall(RunApp)
        at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.ja
va:1231)
| Error Error running script –stacktrace: Cannot invoke method findAll() on null object

The solution is use the class full name:

generate-all helloworld.User

helloworld is my application name. and the User class package is “hellowolrd”.

Many thanks for:  generate-all No domain class found for.. error in grails

Grails: Hello world!

Categories: Development Notes; Tagged with: ; @ December 2nd, 2012 23:57

1. Download Grails, unzip.

2. Add the bin path into PATH

3. run: grails –version, if you not set JAVA_HOME yet, there will be some info about this.

now, you are ready to create the application:

 

1.  Run: grails create-app helloworld  there’ll be some mesg about the application path.
Note: can not use this command in “Interactive Mode”

2. cd helloworld

3. Create controller:  grails>  create-controller  hello, get some info after success:

| Created file grails-app/controllers/helloworld/HelloController.groovy
| Created file grails-app/views/hello
| Created file test/unit/helloworld/HelloControllerTests.groovy

4.  Modify the controller:

package helloworld

class HelloController {

    def index() { 
		render "Hello World!!"
	}
}

5. Ok, everything is ready, now, just run the application:  grails> run-app

image

Negative to the page,  the console will be there, click the application link: “Hello world!!”



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.