Grails 域类缺少静态 get 方法
在使用 grails 的生产中,我们不断地间歇性地收到以下错误。它表示给定的域类没有 get 方法。对于每分钟执行约 300 次的代码,这种情况每隔几天就会发生一次。我们无法重现它。
No signature of method: static DomainClass.get() is applicable for argument types: (java.lang.Long) values: [97]
还有其他人遇到过这个问题吗?我们使用的是 grails 1.3.6。我们的域类上的 id 是 gorm 默认值。我们正在运行 sun jvm 版本 1.6.0_17-b04。
更新:
今天发生错误时我发现了更多信息。我们正在使用 JMS grails 插件,错误发生在接收 JMS 消息的类之一中。看起来 JMS 插件在 grails 完成引导应用程序之前就开始传递消息。如果 grails 启动时队列中有消息,则异常开始出现在日志中。一旦 grails 完全启动,错误就会停止并且消息会正常处理。我的猜测是,grails 内的 spring 上下文是在动态方法添加到域类之前启动的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能会遇到此问题
http://jira.codehaus.org/browse/GRAILS-4467< /a>
有点奇怪的是这种情况只是经常发生。您确定失败的实际方法被频繁调用吗?
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?
正如您所说,域类的 id 是 GORM 默认值,因此 hvgotcodes 指出的 Grails Jira 中的错误不适用于您的情况(它们处理字符串 id)。
我猜想可能是在某个地方,传递到 get() 方法的参数不是“Long 类型”。很容易被忽略,例如GET/POST方法(GORM默认)传递的参数id是字符串类型,使用前需要转换为Long。
例如:
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: