8

启动我的 grails 2.2.0 应用程序时,我随机收到如下错误消息,但它也随机成功启动而没有错误。代码没有变化,我只是尝试运行grails dev run-app多次。

$ grails dev run-app

我之前也尝试grails clean过,但这没有什么区别;错误仍然随机发生。

启动错误:

| Packaging Grails application.....
webxml.WebxmlGrailsPlugin Loading default config file: class DefaultWebXmlConfig
webxml.WebxmlGrailsPlugin Did not find application config file: WebXmlConfig
webxml.WebxmlGrailsPlugin Loading default config file: class DefaultWebXmlConfig
| Running Grails application
context.GrailsContextLoader [GrailsContextLoader] Loading context. Creating parent application context
context.ContextLoader Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
    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:680)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
    ... 5 more
Caused by: java.lang.reflect.InvocationTargetException
    ... 5 more
Caused by: java.lang.NoClassDefFoundError: Lorg/codehaus/groovy/grails/plugins/web/async/api/ControllersAsyncApi;
    at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.plugins.web.async.api.ControllersAsyncApi
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 7 more
context.GrailsContextLoader Error initializing the application: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
    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:680)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
    ... 5 more
Caused by: java.lang.reflect.InvocationTargetException
    ... 5 more
Caused by: java.lang.NoClassDefFoundError: Lorg/codehaus/groovy/grails/plugins/web/async/api/ControllersAsyncApi;
    at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
    at java.lang.Class.getDeclaredFields(Class.java:1743)
    ... 5 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.plugins.web.async.api.ControllersAsyncApi
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 7 more

环境:

  • Mac OS X 狮子
  • JDK 1.6.0_31

类似的帖子,但仍然不同,因为我没有运行 Tomcat:

4

3 回答 3

12

将 servlet 版本从 3.0 更改为 2.5(反之亦然)后,出现了此异常。

我通过键入以下内容解决了这个问题:

grails clean
grails clean-all

已再次获取依赖项并且应用程序开始运行。

于 2013-12-15T19:56:39.043 回答
5

Try to mark your servlet version as v3.0. I had the same sporadic issue and solved it by moving to v.3.0

File: BuildConfig.groovy

grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0)

After that grails-plugin-async-2.2.0.jar appeared on classpath:

%HOME%.grails\ivy-cache\org.grails\grails-plugin-async\jars\

于 2013-04-03T10:44:49.030 回答
0

如果清理不起作用,请尝试手动删除目标。

于 2015-07-20T14:57:11.663 回答