【问题标题】:Grails Rendering Plugin gives java.lang.ClassNotFoundException when deployedGrails 渲染插件在部署时会给出 java.lang.ClassNotFoundException
【发布时间】:2013-01-02 05:53:55
【问题描述】:

我已成功关注此tutorial,并且在 localhost 上运行良好。这是关于使用 grails 渲染插件的。它在 LOCALHOST 上运行良好,但当我部署应用程序时,甚至只是运行 grails run-war,渲染插件不再工作。它给出了一些奇怪的错误。 :(

我正在使用带有渲染插件 0.4.3 的 grails 2.0.0,这就是我的 BuildConfig.groovy 包含的内容:

plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.7.1"
        runtime ":resources:1.1.5"
        compile ":rendering:0.4.3"

        build ":tomcat:$grailsVersion"
    }

错误是这样的:

2012-09-27 17:08:47,714 [http-8643-1] ERROR errors.GrailsExceptionResolver  - ClassNotFoundException occurred when processing request: [GET] /profile/renderFormPDF/1
org.springframework.mock.web.MockHttpServletRequest. Stacktrace follows:
java.lang.ClassNotFoundException: org.springframework.mock.web.MockHttpServletRequest
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
    at java.lang.Class.getDeclaredMethods(Class.java:1791)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
    at grails.plugin.rendering.document.RenderEnvironment.init(RenderEnvironment.groovy:33)
    at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:69)
    at grails.plugin.rendering.document.RenderEnvironment.with(RenderEnvironment.groovy:61)
    at grails.plugin.rendering.document.XhtmlDocumentService.generateXhtml(XhtmlDocumentService.groovy:68)
    at grails.plugin.rendering.document.XhtmlDocumentService.createDocument(XhtmlDocumentService.groovy:38)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:34)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:33)
    at grails.plugin.rendering.RenderingService.render(RenderingService.groovy:63)
    at com.icodeya.ProfileController.renderFormPDF(ProfileController.groovy:108)
    at net.stax.appserver.webapp.RequestMonitorValve.invoke(RequestMonitorValve.java:35)
    at net.stax.appserver.admin.StaxApplicationQueryValve.invoke(StaxApplicationQueryValve.java:49)
    at net.stax.appserver.webapp.RequestSetupValve.invoke(RequestSetupValve.java:31)
    at java.lang.Thread.run(Thread.java:662)

【问题讨论】:

  • 我遇到了同样的问题,但没有解决方案(在 appfog / cloudfoundry 上部署战争)

标签: grails


【解决方案1】:

这是在开发环境中的 spring-test jar 中,但不包含在 WAR 文件中。添加

runtime 'org.springframework:spring-test:3.1.0.RELEASE'

到 BuildConfig.groovy 的 dependencies 部分。

【讨论】:

  • 感谢 Burt,发现这个解决方案在使用 mail 1.0.3 插件时也解决了类似的问题。
  • 如果您使用的是 Grails 2.3.7,请使用 org.springframework:spring-test:3.2.8.RELEASE,因为它是 org.grails:grails-plugin-testing:2.3.7 的依赖项
  • 对于您正在使用的 Grails 版本,运行“grails dependency-report”并找到 org.grails:grails-plugin-testing 的依赖项。其中之一应该是 org.springframework:spring-test:x.x.x.RELEASE 并使用它。
  • 在我的情况下,当我将渲染插件与独立插件一起使用时会发生此问题。对于 Grails 2.4.3,我使用以下版本:runtime 'org.springframework:spring-test:4.0.6.RELEASE' 它就像一个魅力。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-15
  • 2017-09-17
  • 1970-01-01
  • 2017-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多