Missing static get method on Grails Domain Class

1.5k views Asked by At

We keep getting the following error intermittently in production with grails. It says there is no get method for the given domain class. This happens once every few days on code that is executing about 300 times/minute. We haven't been able to reproduce it.

No signature of method: static DomainClass.get() is applicable for argument types: (java.lang.Long) values: [97]

Has anyone else ran into this problem? We are using grails 1.3.6. The id's on our domain classes are the gorm defaults. We are running the sun jvm version 1.6.0_17-b04.

Update:

I found out a little more when the error happened today. We are using the JMS grails plugin, and the error occurs in the one of the classes that is receiving JMS messages. It looks like the JMS plugin starts delivering messages before grails has finished bootstraping the application. If there are messages in the queue when grails starts, the exceptions start appearing in the log. Once grails has started all the way, the errors stop and the messages process normally. My guess is that the spring context inside grails is started before dynamic methods are added to the Domain classes.

2

There are 2 answers

0
Hoàng Long On

As you said that your id for the domain class is GORM default, so the bug in Grails Jira that hvgotcodes points out doesn't apply in your case (they deal with string id).

I guess that it's maybe at somewhere, the argument transfered into get() method is not "Long type". It's very easy to miss, for example, the parameter 'id' transfered by GET/POST method (GORM default) is string type, and need to be converted to Long before using.

For example:

def id = params.id
def object = DomainClass.get(id as Long)
1
hvgotcodes On

You might be running into this issue

http://jira.codehaus.org/browse/GRAILS-4467

what is a bit weird is how this only happens every so often. Are you sure the actual method that is failing is being called that often?