Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix Grails error: "No domain class found for name PrivacyOptions. Please try again and enter a valid domain class name"

Tags:

class

grails

dns

People also ask

How do I add a domain to grails?

If you don't specify a package (like "org. bookstore" in the example), then the name of the application will be used as the package. So if the application name is "bookstore" and you run create-domain-class Book , then the command will create the file grails-app/domain/bookstore/Book.

What is grails domain class?

In Grails a domain is a class that lives in the grails-app/domain directory. A domain class can be created with the create-domain-class command: grails create-domain-class org.bookstore.Book. or with your favourite IDE or text editor.


Add the project name (aka the package name from the first line of the model file) before the model name.

grails generate-all projectname.Class

This is the one that finally worked for me, after an hour of head scratching and googling.

ref: http://grails.1312388.n4.nabble.com/Generate-Scaffold-Scripts-Don-t-Work-Getting-No-domain-class-found-Error-td2017858.html#a2017880

As of 1.2.2 Grails creates artifacts in packages that default to your project name - see http://jira.codehaus.org/browse/GRAILS-5713 So you'd need to run grails generate-all srapp.Srmodel - Burt


it's not projectname.Class , it must be dirname.classname .

eg: your projectname is Helloworld, the directory is "grails-app/domain/helloworld/User.groovy" . so , the command is "grails generate-all helloworld.User" ,but not "Helloworld.User"


Run:

grails clean

and then re-run the generate-all command.

ref: http://parasjain.net/2009/06/23/grails-no-domain-class-found-for-name-please-try-again-and-enter-a-valid-domain-class-name/


Great help. I faced the same problem following this tutorial that names the project as "trip-planner" and Grails generates the domain directories as '~/trip/planner/' instead of '~/trip-planner/'. Then the generate-all command for a Trip class should be 'grails generate-all trip.planner.Trip'

Just in case someone adds a '-' character to the project name.


Yep... worked for me too. I just prefixed the package name to the class I was trying to generate-all for and it worked. So ...

generate-all racetrack.User

Bit of a pants bug really since all other grails commands do not require a package name to be included :-))