【问题标题】:Grails MissingMethodException: createCriteria in WAR, Runs LocallyGrails MissingMethodException:WAR 中的 createCriteria,在本地运行
【发布时间】: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


【解决方案1】:

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

【讨论】:

  • 嗨@john_solo,我在Tomcat服务器中遇到一个错误,如下所示:错误500:内部服务器错误URI /dbsync/DatabaseSync/updateAllDBs类groovy.lang.MissingMethodException消息没有方法签名:静态 java.lang.Math.max() 适用于参数类型:(java.lang.Integer, null) 值:[4, null] 可能的解决方案:max(int, int), max(double, double), max(float, float), max(long, long), min(int, int), wait() 我刚刚添加了一个新的控制器方法,它调用了一个新的服务方法。它在我本地和另一位同事的笔记本电脑上运行良好。
  • 查看答案。我的问题变成了 DataSource.groovy 中的问题。也许您有类似的问题?
【解决方案2】:

请分享domaincontroller 的代码。它毫无例外地对我有用。

步骤:

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

您可以找到详细信息here

要点击的网址:

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

【讨论】:

  • 整个 grails 应用程序使用 run-app 和 run-war 在本地运行良好,只有当我生成战争并部署到 Tomcat 时才会收到错误消息。我有四个控制器,它们都使用createCriteria()withCriteria,它们都有相同的结果。一定是发生了某种奇怪的缓存。
  • 这是使用 createCriteria 的控制器(完全不同的控制器)引发的错误:Error 500: Internal Server Error URI/apps2/mriMetricAdjustment/goalAdjustment/list Classgroovy.lang.MissingMethodException MessageNo signature of method: com.thrivent.mriAdjustment.domain.GoalAdjustment.createCriteria() is applicable for argument types: () values: [] Possible solutions: createCriteria()
  • 嗨@dmahapatro,我在Tomcat服务器中遇到一个错误,如下所示:错误500:内部服务器错误URI /dbsync/DatabaseSync/updateAllDBs类groovy.lang.MissingMethodException消息没有方法签名.我刚刚添加了一个新的控制器方法,它调用了一个新的服务方法。在本地机器上一切都运行良好,我也在不同的机器上尝试过。是浏览器缓存还是 TOMCAT 缓存问题?
  • @ani0904071 我相信最好将您的问题作为一个新问题发布(如果您还没有这样做),以提供更多上下文和详细信息。任何人都需要更多的背景来看待手头的问题。我鼓励您作为新问题发布并添加适当的标签。我已经有几年特别没有使用Grails了,但是如果我有时间我一定会尝试回答这个问题。但是,社区很活跃,任何人都可以回答您的问题。
  • 嗨@dmahapatro,幸运的是这是一个浏览器缓存问题,清除缓存有效!感谢您的回复和之前的解释!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多