ปลั๊กอิน Grails Rendering จะให้ java.lang.ClassNotFoundException เมื่อใช้งาน

ฉันได้ติดตามบทช่วยสอนนี้แล้ว ประสบความสำเร็จและทำงานได้ดีบน localhost มันเกี่ยวกับการใช้ปลั๊กอินการเรนเดอร์ grails มันทำงานได้ดีและทั้งหมดบน LOCALHOST แต่เมื่อฉันปรับใช้แอป หรือแม้แต่เรียกใช้ grails run-war ปลั๊กอินการเรนเดอร์จะไม่ทำงานอีกต่อไป มันมีข้อผิดพลาดแปลกๆ :(

ฉันใช้ 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)

person ShootingStar    schedule 27.09.2012    source แหล่งที่มา
comment
ฉันมีปัญหาเดียวกันและไม่มีวิธีแก้ปัญหา (ปรับใช้ war บน appfog / cloudfoundry )   -  person whitenexx    schedule 01.01.2013


คำตอบ (1)


นั่นอยู่ในขวดทดสอบสปริงซึ่งอยู่ในสภาพแวดล้อม dev แต่ไม่รวมอยู่ในไฟล์ WAR เพิ่ม

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

ไปที่ส่วน dependencies ของ BuildConfig.groovy

person Burt Beckwith    schedule 01.01.2013
comment
ขอบคุณ Burt พบว่าโซลูชันนี้ยังแก้ไขปัญหาที่คล้ายกันเมื่อใช้ปลั๊กอิน mail 1.0.3 - person arcseldon; 07.03.2014
comment
หากคุณใช้ Grails 2.3.7 ให้ใช้ org.springframework:spring-test:3.2.8.RELEASE เนื่องจากขึ้นอยู่กับ org.grails:grails-plugin-testing:2.3.7 - person genuinefafa; 10.04.2014
comment
สำหรับเวอร์ชันของ Grails ที่คุณใช้ ให้เรียกใช้ grails dependency-report และค้นหาการอ้างอิงสำหรับ org.grails:grails-plugin-testing หนึ่งในนั้นควรเป็น org.springframework:spring-test:x.x.x.RELEASE และใช้สิ่งนั้น - person AndrewW; 05.08.2014
comment
ในกรณีของฉัน ปัญหานี้เกิดขึ้นเมื่อฉันใช้ปลั๊กอินการเรนเดอร์ร่วมกับปลั๊กอินแบบสแตนด์อโลน สำหรับ Grails 2.4.3 ฉันใช้เวอร์ชันต่อไปนี้: runtime 'org.springframework:spring-test:4.0.6.RELEASE' และมันใช้งานได้อย่างมีเสน่ห์ - person cantoni; 06.01.2015