2012-09-27 112 views
11

我已成功地遵循此tutorial,並且在本地主機上運行良好。這是關於使用使用grails渲染插件。它在LOCALHOST上運行良好,但是當我部署應用程序,或者甚至只運行grails run-war時,渲染插件不再有效。它給出了一些奇怪的錯誤。 :(Grails渲染插件在部署時給出java.lang.ClassNotFoundException

我使用Grails 2.0.0渲染插件0.4.3,這是我的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) 
+0

我有同樣的問題,沒有解決方案(在appfog/cloudfoundry上部署的戰爭) – whitenexx

回答

34

這在開發環境中,但不包含在WAR文件中的彈簧測試罐中。添加

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

到BuildConfig.groovy的部分。

+0

謝謝Burt!這與grails 2.2一起工作! – whitenexx

+1

也適用於我,很高興這個答案存在 – JavaDev

+2

謝謝伯特,發現這個解決方案也解決了使用郵件1.0.3插件時類似的問題。 – arcseldon