这是我的控制者:
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', 'org.apache.jasper.compiler.TldLocationsCache@63e3f789')
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 :(得分:0)
您的日志中有多个错误,但它们都归结为FileManageService不存在。你没有在这里提供整个服务(你真的不需要),但我的猜测是该文件中某处存在编译错误,并且没有成功编译。因此,它不包含在您的应用程序中,并且在您调用它时不存在。
使用您的IDE(如果您有一个,如果没有,可以使用免费的IDE!请查看Intellij!)以跟踪代码中的错误。