Sunday, July 7, 2013

Grails generate-all No domain class found for name

Problem :

I'm try to use "generate-all" command and I had this error message each time I use it : "No domain class found for name User".
I typed this command :

grails generate-all User


I use Grails 2.1.5 so perhaps it works better in last version ;-)

Error :
| No domain class found for name User. Please try again and enter a valid domain
 class name
| Error 2013-06-30 13:51:40,907 [Thread-10] ERROR plugins.DefaultGrailsPlugin  -
 Error configuration scaffolding: Error creating bean with name 'instanceControl
lersApi': Singleton bean creation not allowed while the singletons of this facto
ry are in destruction (Do not request a bean from a BeanFactory in a destroy met
hod implementation!)
Message: Error creating bean with name 'instanceControllersApi': Singleton bean
creation not allowed while the singletons of this factory are in destruction (Do
 not request a bean from a BeanFactory in a destroy method implementation!)
   Line | Method
->> 722 | run in java.lang.Thread


Solution

grails generate-all racetrack.User
In fact, my domain class was in a directory named racetrack.
I have the following tree directory : $GRAILS_APPdomain/racetrack/User.java


Saturday, July 6, 2013

Grails automatic timestamp

In your domain class, you can add a field which has automatic timestamp (When creating or when updating).
The date field must have the name dateCreated or lastUpdated.
It's a convention define by Grails.

Example :

class Person {
   Date dateCreated
   Date lastUpdated
}
 
 
If you want to disable this feature, you can make the following :
 
class Person {
   Date dateCreated
   Date lastUpdated
   static mapping = {
      autoTimestamp false
   }
} 

See also :

Learn Grails with a book


I'm learning Grails.
I choose "Grails getting started" because it's easy to understand and not annoying :-)
I appreciate this book that's why I post this link : http://www.infoq.com/minibooks/grails-getting-started

Tuesday, July 2, 2013

Grails : Do you know CRaSH plugin ?

Grails



You have the possibility to embeded CRaSH in Grails by installing the CRaSH plugin.
It's very easy :

cd $PATH_TO_MY_GRAILS_APPLICATION
grails install-plugin crash


Now, you can connect to your Grails application by using CRaSH.
Two steps for that :
  • Find the Java Process PID of your Grails application with :
cd $JAVA_HOME/bin
jps
  • Launch CRaSH
Then you will be able to access to CRaSH command by typing :

cd $CRASH_HOME/bin
crash.sh PID

Now, you have access to all CRaSH command jdbc,jpa, thread ... and you can make your own !

CRaSH web site : http://www.crashub.org/
Grails CRaSH plugin : https://github.com/crashub/grails
Grails : http://grails.org/