与grails run-war的错误

时间:2011-10-23 12:45:10

标签: tomcat grails

我有grails应用程序,在运行应用程序时 - 一切正常!但是之后:grails run-war,我得到了一个错误:

 
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 'd1LdapServer': Invocation of init method failed; nested exception is groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.io.File#.

Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:

    [class java.io.File, class java.lang.String]

    [class java.lang.String, class java.lang.String]

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

    at java.util.concurrent.FutureTask.run(FutureTask.java:138)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    at java.lang.Thread.run(Thread.java:662)

Caused by: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.io.File#.

Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:

    [class java.io.File, class java.lang.String]

    [class java.lang.String, class java.lang.String]

    at grails.ldap.server.TransientGrailsLdapServer.getWorkDir(TransientGrailsLdapServer.groovy:265)

    at grails.ldap.server.TransientGrailsLdapServer.startDirectoryService(TransientGrailsLdapServer.groovy:208)

    at grails.ldap.server.TransientGrailsLdapServer.start(TransientGrailsLdapServer.groovy:79)

    at grails.ldap.server.TransientGrailsLdapServer.afterPropertiesSet(TransientGrailsLdapServer.groovy:67)

感谢任何帮助。谢谢!

2 个答案:

答案 0 :(得分:1)

在tomcat上部署时,“ldap-server”插件存在同样的问题。 对我来说,修复是通过ApplicationHolder提供servletContext

代替:

ServletContextHolder.servletContext

使用:

ApplicationHolder.application.parentContext.servletContext

TransientGrailsLdapServer.getWorkDir()的完整源代码:

import org.codehaus.groovy.grails.commons.ApplicationHolder

private getWorkDir() {      
    def base = ApplicationHolder.application.parentContext.servletContext ? WebUtils.getTempDir(ApplicationHolder.application.parentContext.servletContext) : new File(BuildSettingsHolder.settings?.projectWorkDir, beanName)
    new File(base, "ldap-servers/$beanName")
}

答案 1 :(得分:0)

问题是由行

中的基本参数为空引起的

新文件(base,“ldap-servers / $ beanName”)

in grails.ldap.server.TransientGrailsLdapServer.getWorkDir()

这指出了一个配置问题,也许你的环境之间存在一些差异导致base参数为null?