2017-07-10 73 views
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 

誰能幫我弄清楚是什麼原因導致了這個錯誤?

回答

0

您的日誌中有多個錯誤,但都歸結爲FileManageService不存在的事實。你沒有在這裏提供整個服務(你也不需要),但我的猜測是該文件中存在編譯錯誤,並且它沒有成功編譯。因此,它不包含在您的應用程序中,並且在您調用它時不存在。

使用你的IDE(如果你有一個,如果你沒有,有很好的免費可用的!看看Intellij!)來追蹤代碼中的錯誤。

+0

另外,按照慣例,不要用第一個大寫字母來命名方法。這使得它看起來像一個內部類,真的讓調試變得更加困難! – Daniel

+0

該應用程序在添加代碼片段之前工作完美,當我刪除服務方法並部署時,它又成功編譯了。 –

+0

你的File對象是什麼?我沒有在java.io.File上看到getSpace()方法,或Groovy對它的增強。 – Daniel