grails run-app randomly throws: java.lang.NoClassDefFoundError: Lorg/codehaus/groovy/grails/plugins/web/async/api/ControllersAsyncApi
Asked Answered
B

3

8

When starting my grails 2.2.0 app, I am randomly getting the error message as below, but it also randomly succeeds starting the up without an error. No changes to the code, I just try to run the grails dev run-app multiple times.

$ grails dev run-app

I also tried a grails clean before, but that makes no difference; the error still randomly occurs.

Errors on startup:

| 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

Environment:

  • Mac OS X Lion
  • JDK 1.6.0_31

Similar post, but still different, as I'm not running Tomcat:

Bering answered 27/3, 2013 at 8:22 Comment(3)
You can try to use an utility like jarscan java.net/projects/jarscan and check if you have different version of the same lib in your appSeymour
Run-app uses the tomcat plugin by default - unless you have installed the jetty plugin. Did you run grails upgrade at any point? I've been seeing some strange behaviour with 2.2.0 after running grails upgrade. Maybe give the jetty plugin a try?Permeance
fyi - I updated rom grails 2.2.0 to grails 2.2.1 and haven't had the issue yet. Will observe further.Bering
F
12

After changing servlets version from 3.0 to 2.5 (and vice versa) and this exception appeared.

I have resolved this problem by typing:

grails clean
grails clean-all

The dependencies has been fetched again and application began running.

Fingering answered 15/12, 2013 at 19:56 Comment(0)
S
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\

Splutter answered 3/4, 2013 at 10:44 Comment(0)
F
0

Try to remove target manually in case the clean do not work.

Freeswimming answered 20/7, 2015 at 14:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.