Grails MissingMethodException:WAR中的createCriteria,在本地运行

时间:2013-04-19 20:20:48

标签: grails createcriteria

我有一个非常香草的Grails应用程序。控制器上的域对象。当使用run-app或run-war在本地使用时,一切运行正常。当我使用grails war创建WAR文件并部署到Tomcat 7.0.25 webapps目录时,我得到以下内容:

  

错误500:内部服务器错误   URI / APPS 2 / mriMetricAdjustment / teamResultAdjustment /名单   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工具套件3.1.0,Grails 2.1.1。任何帮助将不胜感激。

添加堆栈跟踪和代码以解决问题。每个控制器中的相同位置:

  

[2013-04-19 16:51:43.931] sysCorpMRIMetricAdjustments   ajp-bio-8018-exec-2 ERROR   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()。 Stacktrace如下:   groovy.lang.MissingMethodException:没有方法签名:   com.thrivent.mriAdjustment.domain.TeamResultAdjustment.withCriteria()   适用于参数类型:()值:[]可能的解决方案:   withCriteria(groovy.lang.Closure),withCriteria(java.util.Map,   groovy.lang.Closure),createCriteria()at   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 + "%") } }

使用错误的日志和堆栈跟踪中的代码段进行了更新。是否需要清除Tomcat缓存?

  

[2013-04-22 08:42:33.414] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 DEBUG> ngframework.beans.factory.support.DefaultListableBeanFactory - debug返回缓存>单例bean'grailsApplication'的实例   [2013-04-22 08:42:33.432] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 DEBUG> ngframework.beans.factory.support.DefaultListableBeanFactory - debug返回缓存>单例bean'grailsApplication'实例   [2013-04-22 08:42:33.438] sysCorpMRIMetricAdjustments ajp-bio-8018-exec-4 ERROR> rg.codehaus.groovy.grails.web.errors.GrailsExceptionResolver - error>处理请求时发生MissingMethodException:[GET ] / apps2 / mriMetricAdjustment> / goalAdjustment / list   没有方法签名:com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria()>适用于参数类型:()值:[]   可能的解决方案:createCriteria()。 Stacktrace如下:   groovy.lang.MissingMethodException:没有方法签名:> com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria()适用于>参数类型:()值:[]   可能的解决方案:createCriteria()     at> com.thrivent.mriAdjustment.controller.GoalAdjustmentController.list(GoalAdjustmentController.groovy:33)     at> grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilte> r.java:195)     at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)     at> java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886)>       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908)     在java.lang.Thread.run(Thread.java:662)

`     插件{         运行时“:hibernate:$ grailsVersion”         运行时“:jquery:1.8.0”         runtime“:resources: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"
}`

最后但并非最不重要的一点 - 卡塔琳娜记录了我发动战争的时间:

>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)

2 个答案:

答案 0 :(得分:0)

请分享domaincontroller的代码。它毫无例外地为我工作。

<强>步骤:

  • 创建demoApp
  • 创建domain
  • 创建controller
  • 来自withCriteria操作
  • index()使用
  • grails war
  • 将部署的WAR部署到Tomcat 7.0.39(最新版)

您可以找到详细信息here

要点击的网址:

http://localhost:8080/demoApp-0.1/foo?name=Foo

答案 1 :(得分:0)

因此,这与应用程序WAR无关,而是与DataSource.groovy的服务器配置不匹配。该服务器名为&#39; systst&#39;但是DataSource.groovy中的环境被标记为&#39; syst * e * st。&#39;我怀疑GORM配置从未发生过,因为数据源配置从未加载过。没有错误消息,但是我会认为Domain对象会因为我在域中引用数据源名称而失败。谢谢大家!