0
這是我的控制器:的Tomcat無法啓動的Grails applocation
def delete(){
def response = fileManageService.delete(params.a,params.b,params.c)
def SpaceVal = fileManageService.Space(params.d)
def message = ["message":response ,"data": SpaceVal]
render message as JSON
}
這是我的服務:
def Space(def d){
try{
File fileObj = new File(d)
def useSpace = fileObj.getSpace()
return useSpace
}catch(Exception e){
return e.getMessage();
}
}
將代碼添加到現有的工作程序後,Tomcat是無法編譯代碼並引發以下日誌錯誤。
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', '[email protected]')
Jul 10, 2017 11:22:11 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jul 10, 2017 11:22:11 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jul 10, 2017 11:22:12 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/mediacast/services/FileManageService$_driveSpace_closure18
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:762)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: com/mediacast/services/FileManageService$_driveSpace_closure18
at java.lang.Class.forName(Class.java:249)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.mediacast.services.FileManageService$_driveSpace_closure18
... 6 more
Jul 10, 2017 11:22:20 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jul 10, 2017 11:22:21 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jul 10, 2017 11:22:22 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/mediacast/services/FileManageService$_Space_closure18
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: com/mediacast/services/FileManageService$_Space_closure18
at java.lang.Class.forName(Class.java:249)
... 3 more
Caused by: java.lang.ClassNotFoundException: com.mediacast.services.FileManageService$_Space_closure18
誰能幫我弄清楚是什麼原因導致了這個錯誤?
另外,按照慣例,不要用第一個大寫字母來命名方法。這使得它看起來像一個內部類,真的讓調試變得更加困難! – Daniel
該應用程序在添加代碼片段之前工作完美,當我刪除服務方法並部署時,它又成功編譯了。 –
你的File對象是什麼?我沒有在java.io.File上看到getSpace()方法,或Groovy對它的增強。 – Daniel