【发布时间】:2013-04-13 08:02:06
【问题描述】:
我有一个非常普通的 Grails 应用程序。控制器上的域对象。在本地使用 run-app 或 run-war 时,一切运行良好。当我使用 grails war 创建 WAR 文件并部署到 Tomcat 7.0.25 webapps 目录时,我得到以下信息:
错误 500:内部服务器错误 URI/apps2/mriMetricAdjustment/teamResultAdjustment/list Classgroovy.lang.MissingMethodException MessageNo 方法签名: com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[] 可能的解决方案: withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure), createCriteria()
withCriteria() 是域方法,此错误出现在所有域对象上。我已经尝试了各种清洁、刷新依赖项、战争构建中的各种环境切换(如在 grails prod war 中)。我已经完全摧毁了 Tomcat 上的应用程序并重新部署。没有。我正在使用 Groovy Grails Tool Suite 3.1.0、Grails 2.1.1。任何帮助将不胜感激。
在遇到问题的地方添加堆栈跟踪和代码。每个控制器的相同位置:
[2013-04-19 16:51:43.931] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-2 错误 rg.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - 错误 处理请求时发生 MissingMethodException:[GET] /apps2/mriMetricAdjustment/teamResultAdjustment/list 没有签名 方法: com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[] 可能的解决方案: withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure)、createCriteria()。堆栈跟踪如下: groovy.lang.MissingMethodException:没有方法签名: com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria() 适用于参数类型:() 值:[] 可能的解决方案: withCriteria(groovy.lang.Closure), withCriteria(java.util.Map, groovy.lang.Closure), createCriteria() 在 com.thrivent.mriAdjustment.controller.TeamResultAdjustmentController.list(TeamResultAdjustmentController.groovy:34) 在 grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195) 在 grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) 在 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 在 java.lang.Thread.run(Thread.java:662)
def results = TeamResultAdjustment.withCriteria {
and {
like("recordStatusCode", "A")
like ("teamID", "%" + params.tsID + "%")
}
}
使用来自错误日志和堆栈跟踪的 sn-p 进行了更新。是否有需要清除的 Tomcat 缓存?
[2013-04-22 08:42:33.414] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 调试 >ngframework.beans.factory.support.DefaultListableBeanFactory - 调试返回缓存 >单例 bean 'grailsApplication' 的实例 [2013-04-22 08:42:33.432] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 调试>ngframework.beans.factory.support.DefaultListableBeanFactory - 调试返回缓存>单例bean'grailsApplication'的实例 [2013-04-22 08:42:33.438] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 错误 >rg.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - 处理请求时发生错误 >MissingMethodException:[GET] / apps2/mriMetricAdjustment>/goalAdjustment/list 没有方法签名:com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria() >适用于参数类型:() 值:[] 可能的解决方案:createCriteria()。堆栈跟踪如下: groovy.lang.MissingMethodException:没有方法签名:>com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria() 适用于 >argument 类型:() 值:[] 可能的解决方案:createCriteria() 在 >com.thrivent.mriAdjustment.controller.GoalAdjustmentController.list(GoalAdjustmentController.groovy:33) 在 >grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilte>r.java:195) 在 grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) 在 >java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)> 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 在 java.lang.Thread.run(Thread.java:662)
` 插件{ 运行时 ":hibernate:$grailsVersion" 运行时“:jquery:1.8.0” 运行时“:资源:1.1.6”
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.4"
build ":tomcat:$grailsVersion"
//build ":hibernate:$grailsVersion"
runtime ":database-migration:1.1"
compile ':cache:1.0.0'
compile ":grails-ui:1.2.3"
compile ":yui:2.8.2.1"
compile ":bubbling:2.1.4"
compile ":searchable:0.6.4"
compile ":jquery-ui:1.8.24"
compile ":jquery-datatables:1.7.5"
//compile ":hibernate:$grailsVersion"
}`
最后但同样重要的是 - 我重新安装战争时的 catalina 日志:
>Apr 22, 2013 11:50:22 AM org.apache.catalina.startup.HostConfig checkResources
>INFO: Undeploying context [/apps2/mriMetricAdjustment]
>Apr 22, 2013 11:50:22 AM org.apache.catalina.startup.HostConfig deployWAR
>INFO: Deploying web application archive /opt/Apache/Tomcat7.0.25/profiles/sysCorpMRIMetricAdjustments/webapps/apps2#mriMetricAdjustment.war
>Apr 22, 2013 11:50:26 AM org.apache.catalina.core.ApplicationContext log
>INFO: Initializing Spring root WebApplicationContext
>Apr 22, 2013 11:50:55 AM org.apache.catalina.core.ApplicationContext log
>INFO: Initializing Spring FrameworkServlet 'grails'
>Apr 22, 2013 11:54:19 AM org.apache.catalina.core.ApplicationContext log
>INFO: Initializing Spring FrameworkServlet 'gsp'
>Apr 22, 2013 11:54:19 AM org.apache.catalina.core.ApplicationContext log
>INFO: GSP servlet initialized
还有一个更新...这是我安装的插件:
Plug-ins you currently have installed are listed below:
-------------------------------------------------------------
bubbling 2.1.4 -- Bubbling Library YUI Extension
cache 1.0.0 -- Cache Plugin
database-migration 1.1 -- Grails Database Migration Plugin
grails-ui 1.2.3 -- Grails UI
hibernate 2.1.1 -- Hibernate for Grails
jquery 1.8.0 -- JQuery for Grails
jquery-datatables 1.7.5 -- JQuery DataTables Plugin
jquery-ui 1.8.24 -- jQuery UI resources
resources 1.1.6 -- Resources
searchable 0.6.4 -- Searchable Plugin
tomcat 2.1.1 -- Apache Tomcat plugin for Grails
webxml 1.4.1 -- WebXmlConfig
yui 2.8.2.1 -- Yahoo! User Interface Library (YUI)
【问题讨论】:
-
在上面添加了代码和堆栈跟踪。
-
只是为了好奇,如果您更改为 Domain.createCriteria().list(){} 是否有效?
-
不,如果没有。看到这个错误后,我实际上是从 createCriteria 更改了它。
-
在全新安装 Tomcat 后问题会消失吗?
-
既然这是我公司的测试区域,我将无法对其进行测试。多次 JVM 和/或 Tomcat 重新启动后,该问题并未消失。
标签: grails createcriteria