Tag Archives: Grails

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

22 Jun

Short Story: Provide fully qualified domain class name(class name with the package) to the generate-all command

Long Story:

If you have recently moved from pre-1.3 to latest grails version(1.3.2 as of today) and suddenly you have started getting this error

No domain class found for name Book. Please try again and enter a valid domain class name

on generate-all command


grails generate-all Book

then don’t panic. As of grails-1.3.2, when you create a new domain class, it is generated in a package. For example, in my case my Book.groovy is generated under mylib package(mylib is the name of my application)

generate-all command requires you provide fully qualified class names. This is true for even older versions like 1.1.1.

Issue this command instead


grails generate-all mylib.Book

I wish they made this point clear in their documentation at http://grails.org/doc/latest/ref/Command%20Line/generate-all.html

Grails EHCache Settings

11 Jun

We have configured Ehcache as second level hibernate cache for our project. This post is for Grails 1.1.1 projects. In the later version of grails, the configuration can be little different. Here are the steps. (It is quite some time when I did the actual configuration. Let me know if I missed something)

i)

First of all we have put ehcache.xml in grails-app/conf directory. Our config file looks like this.  You may modify the config based on your preferences. To learn more about this settings go to http://ehcache.org/documentation/configuration.html


<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="ehcache.xsd">
 <defaultCache
    maxElementsInMemory="1000"
    eternal="false"
    timeToIdleSeconds="3600"
    timeToLiveSeconds="3600"
    overflowToDisk="false"
    diskPersistent="false"
    diskExpiryThreadIntervalSeconds="120"
    memoryStoreEvictionPolicy="LRU"
 />

 <cache name="org.hibernate.cache.UpdateTimestampsCache"
        maxElementsInMemory="10000"
        timeToIdleSeconds="300"
 />

 <cache name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="10000"
        timeToIdleSeconds="300"
 />

</ehcache>

ii) Modify the cache provider class in your DataSource.groovy to org.hibernate.cache.EhCacheProvider like this

hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.provider_class='org.hibernate.cache.EhCacheProvider'
}

iii) Now to fine-tune your cache setting, go to individual domain classes for which you want to enable ehcache and add the following mapping closure with cache true

class Employee {
    String name
    ........
    ........
    static constraints = {
        ....
    }

    static mapping = {
        cache true
    }
}

iv) If you want your query to be cached, you can configure it similarly with cache true clause

		def employeeList = Employee.createCriteria().list() {
			or {
				......
			}
			order(".....", "...")
			cache true
		}

For further reading to to http://ehcache.org/documentation/grails.html

Creating Acegi Users in a script

6 Oct

We are using Acegi plugin for Authentication and Authorization in Grails. We had to create users in bulk using MySql script. We have to know the encrypted password for each user, corresponding to the clear text password to insert in the database. (Acegi encrypts the password before storing it in the database).

I came across this nice post http://stackoverflow.com/questions/1472431/acegi-password-encryption

I was also thinking that Acegi must be using MD5, but after reading this post realized that it is SHA1 encryption.

You can get the sha1 encrypted password by issuing this command

echo -n password | openssl sha1

For eg. if your password is admin you can find encrypted password by issuing this command

echo -n admin | openssl sha1

Running grails at some specific port

7 Jul

By default, jetty will run the application at port 8080, but if you want to run the application at some specific port, for example 8085 you should use

grails -Dserver.port=8085 run-app

Grails : No domain class found for name domain-class-name . Please try again and enter a valid domain class name

23 Jun

Sometimes, even if you create domain objects in grails you get the error that No domain class found.
I am not sure why this happens because I am new to Grails and still learning. But the following steps work for me

i) Stop all the running grails app ctrl+C
ii) grails clean
iii) Now try grails generate-all domain-class-name

This generally works for me. I will update this post if I find the root cause of the problemSom

Beginning Groovy and Grails

1 May

In the last session on April 13, 2009 on Jazz and Rational Team Concert at TCJUG , I have won the book Beginning Groovy and Grails: From Novice to Professional (Beginning from Novice to Professional) in the lucky draw.

Beginning Groovy and Grails

This is happening second time in the row that I have attended JUG meeting with Groovy message. In my last meeting the topic of discussion itself was groovy and this time around, it is the book. The message is loud and clear. Looks like everyone has started taking Groovy seriously. People consider it as gen-next Java language. After all, Groovy is not something which poises itself to compete with Java language. In fact it builds itself over the Java language. You run groovy programs on JVM. While relieving developers of many of the pains which comes with java, groovy provides many powerful features, missing and long sought in Java.
Having said that, I am still a doubtful thomas, when it comes to new technology. To build a secure, scalable, robust application, I would not put my bets on Grails. At least for now.

By the way the presentation slides for Jazz are not there yet on TCJUG website. Check http://jazz.net/ for more details.
Jazz is also a wonderful framework address the concerns of the entire life-cycle of project development. From requirement analysis to design and development; from testing to maintenance; from project management to project change management; it is built on the vision to provide one -stop- shop for all the needs.
Rational Team Concert is the product built on Jazz framework. The speaker has demonstrated many cool features of RTC. It integrates IDE, testing environment, team collaboration, version and cofiguration management, quality management in the other words absolutely every tool we use daily during the software lifecycle. It integrates all these tools at one place. PM will have the clear and accurate picture what is going on with the status and updates of each and every developer, tester will now what fixes developers are working on etc etc. Worth checking out. As far as I remember, the speaker said that this product is relatively new but it has achieved record sales in its category in IBM.

Follow

Get every new post delivered to your Inbox.