Grails Rendering Plugin在部署时提供java.lang.ClassNotFoundException

Sho*_*tar 11 grails

我成功地学习了本教程并且在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"
    }
Run Code Online (Sandbox Code Playgroud)

错误是这样的:

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)
Run Code Online (Sandbox Code Playgroud)

Bur*_*ith 35

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

runtime 'org.springframework:spring-test:3.1.0.RELEASE'
Run Code Online (Sandbox Code Playgroud)

dependenciesBuildConfig.groovy 的部分.

  • 对于您正在使用的Grails版本,运行"grails dependency-report"并找到org.grails的依赖项:grails-plugin-testing.其中一个应该是org.springframework:spring-test:xxxRELEASE并使用它. (6认同)
  • 如果您使用的是Grails 2.3.7,请使用`org.springframework:spring-test:3.2.8.RELEASE`,因为它是_org.grails的依赖项:grails-plugin-testing:2.3.7_ (3认同)
  • 谢谢Burt,发现这个解决方案在使用邮件1.0.3插件时也解决了类似的问题. (2认同)