Trying to get our application up and running with 2.4.0.RC1 and I keep running into this error:
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [grails.plugin.cache.CustomCacheKeyGenerator]: Constructor threw exception; nested exception is java.lang.RuntimeException: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
... 4 more
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
at grails.plugin.cache.CustomCacheKeyGenerator.<init>(CustomCacheKeyGenerator.java:46)
... 4 more
Caused by: java.lang.ClassNotFoundException: org.springframework.cache.interceptor.SimpleKeyGenerator
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName(Class.java:190)
at grails.plugin.cache.CustomCacheKeyGenerator.<init>(CustomCacheKeyGenerator.java:43)
... 4 more
I've upgraded to the latest version of cache (1.1.6). It seems like some kind of version conflict with the spring cache stuff, but I checked the dependency report and didn't see anything unusual being pulled in.
Anyone else run into this problem and have a solution?
It turns out that spring-integration-core version 3.0.3 was including an older version of spring-context that I missed.
Upgrading to spring-integration-core version 4.0.0 uses the same version of Spring 4 as Grails.
Related
I'm using spring-data-elasticsearch:4.3.2 and spring-boot-starter:2.6.4, I can navigate to the RescorerQuery class in Intellij but upon bootstrapping, it logs this error:
Caused by: java.lang.NoClassDefFoundError: org/springframework/data/elasticsearch/core/query/RescorerQuery
at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
... 35 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.data.elasticsearch.core.query.RescorerQuery
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 39 common frames omitted
Update: Turns out it is due to version compatibility. If I change spring-boot-starter to version 2.5.5 it works perfectly. However RescorerQuery is not recommended since it will make the query time a lot longer.
I am using Grails 3.0.3, and added an integration test using create-integration-test and getting this error with both application.yml and application.groovy.
java.lang.IllegalStateException
Caused by: org.springframework.beans.factory.BeanCreationException
Caused by: org.springframework.beans.factory.BeanCreationException
Caused by org.springframework.beans.factory.BeanCreationException
Caused by: java.lang.NullPointerException
Can you please help? Basically I want to know how to do integration test with Grails 3.0.3?
I'm having an issue using Grails on my machine... Java's installed, Groovy's working, but Grails always fails with a RootLoader class not found issue.
I've tried multiple Java/Groovy/Grails combinations to no effect.
Here's the entire output of my console
C:\Users\west>groovy --version
Groovy Version: 2.4.3 JVM: 1.7.0_45 Vendor: Oracle Corporation OS: Windows 7
C:\Users\west>grails --version
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/t
ools/RootLoader
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.RootLoade
r
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
Grails version 2.4.1 was recently released. One of the bugs fixed was restoring the ability to use servlet version 2.5. See https://jira.grails.org/browse/GRAILS-11466
I created a new grails app. Without changing anything, I was able to compile it and run it. When I changed the grails.servlet.version to "2.5", I was able to compile but when I ran it I got the the following stack trace error.
Does anyone know if there are other settings I need to change to get Grails 2.4.1 to run on a servlet 2.5 container? Specifically, tomcat 6.
Error loading plugin manager: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.RuntimeException: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:684)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
Caused by: java.lang.reflect.InvocationTargetException
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:1002)
... 19 more
Caused by: java.lang.NoClassDefFoundError: Lorg/codehaus/groovy/grails/plugins/web/async/api/ControllersAsyncApi;
at org.springsource.loaded.ri.ReflectiveInterceptor.jlClassGetDeclaredFields(ReflectiveInterceptor.java:1593)
... 20 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.plugins.web.async.api.ControllersAsyncApi
... 21 more
Error |
Error loading plugin manager: Unable to locate constructor with Class parameter for class org.codehaus.groovy.grails.commons.DefaultGrailsControllerClass
Error |
Forked Grails VM exited with error
Process finished with exit code 1
This error would happen if you didn't do a grails clean prior to running Grails after changing the version to 2.5
What happens is that when the version is 3.0 Grails adds extra dependencies to the classpath that result in new behaviour being added to the compiled classes.
If you then change the version to 2.5 and just do run-app the extra dependencies are gone, but the new behaviour is still compiled into the classes. Doing a clean resolve this.
When using tika-1.4 getting this:
Caused by: java.lang.NoClassDefFoundError: net/sf/cglib/core/DebuggingClassWriter
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
... 5 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.core.DebuggingClassWriter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
Added these two lines into BuildConfig.groovy:
compile ("org.apache.tika:tika-core:1.4")
compile ("org.apache.tika:tika-parsers:1.4") {excludes "tika-core"}
If I don't exclude tika-core from tika-parsers, I'm getting 2 versions of tika-core (version 1.0 pulled by vorbis-java-tika dependency) and version tika-core version 1.4.
If I replace tika version to be 1.3, exception is gone.
UPDATE 1
This solution seems works:
compile ("org.apache.tika:tika-core:${tikaVersion}")
compile ("org.apache.tika:tika-parsers:${tikaVersion}") { excludes "tika-core", "commons-codec", "commons-logging", "slf4j-api" }
This may or may not be the issue you're seeing -- we're working with tika 1.5 (snapshot). That version pulls in asm-debug-all, which was the cause of our troubles (similar stacktrace to yours). Try using 'asm-debug-all' in your tika-parsers excludes instead of 'tika-core'.