Grails 3.0.3, Error running intrgration test using test-app - grails

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?

Related

Grails 2.5.3 NPE on production deployment (assets-pipeline)

I got the following stacktrace when I try to access login page of my application:
21.03.2016 19:01:52,746: (HVK3) GrailsExceptionResolver: NullPointerException occurred when processing request: [GET] /wmp-hvk3-development/login/auth
Stacktrace follows:
org.codehaus.groovy.grails.web.pages.exceptions.GroovyPagesException: Error processing GroovyPageView: null
at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62)
at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.hash(Hashtable.java:262)
at java.util.Hashtable.get(Hashtable.java:459)
at java.util.Properties.getProperty(Properties.java:951)
at asset.pipeline.grails.AssetProcessorService.getResolvedAssetPath(AssetProcessorService.groovy:57)
at asset.pipeline.grails.AssetProcessorService.asset(AssetProcessorService.groovy:72)
at asset.pipeline.grails.CachingLinkGenerator.asset(CachingLinkGenerator.groovy:32)
at asset.pipeline.grails.CachingLinkGenerator.resource(CachingLinkGenerator.groovy:24)
at gsp_wmpHvk3Development_loginauth_gsp$_run_closure2.doCall(gsp_wmpHvk3Development_loginauth_gsp.groovy:67)
Application works perfectly in test environment on local workstation but this stacktrace occurs when I deploy to production.
Im not sure what to make out of it, I guess there is a problem with the assets-pipeline assets path since AssetProcessorService.groovy:57 states:
I'm on RedHat linux running tomcat 7 with java 1.7 with assets pipeline 2.7.2 plugin as compile dependency and spring security core plugin 2.0.0 compile time dependency.
This was caused by missing configuration in BuildConfig. I added the following to the end of the file and it fixed this:
// This closure is passed the command line arguments used to start the war process.
grails.war.copyToWebApp = { args ->
fileset(dir: "web-app") {
include(name: "js/**")
include(name: "css/**")
include(name: "WEB-INF/**")
}
}

How do I fix this: "ClassDefFoundError: org/codehaus/groovy/grails/commons/ConfigurationHolder"?

I was trying to run my grails project which I upgraded to 2.4.4 from 2.3.5.
Now after trying to run it, I get these error:
|Running Grails application
context.GrailsContextLoaderListener Error initializing the application: org/codehaus/groovy/grails/commons/ConfigurationHolder
java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/commons/ConfigurationHolder
at grails.plugin.hibernate3.HibernatePluginSupport$__clinit__closure1.doCall(HibernatePluginSupport.groovy:129)
at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:754)
at grails.spring.BeanBuilder.beans(BeanBuilder.java:584)
at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:527)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.commons.ConfigurationHolder
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)
... 8 more
Error |
Forked Grails VM exited with error
Based on Grail's migration doc, it looks like they have remove ConfigurationHolder from 2.4.
You need to update the hibernate plugin.
From their doc:
Static Holder Classes The following deprecated classes have been
removed from Grails 2.4.x:
org.codehaus.groovy.grails.commons.ApplicationHolder
org.codehaus.groovy.grails.commons.ConfigurationHolder
org.codehaus.groovy.grails.plugins.PluginManagerHolder
org.codehaus.groovy.grails.web.context.ServletContextHolder
org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder
If you or any plugins you have installed are using these classes you
will get a compilation error. The problem can be rectified by updating
to new plugins and using grails.util.Holders instead.
If your application uses the jquery plugin you will need to update to
version 1.11.0.2 or later as previous versions of the plugin made use
of the ApplicationHolder class. If your application uses the resources
plugin you will need to update to version 1.2.7 or later as previous
versions of the plugin made use of the ConfigurationHolder class.
migration doc: http://grails.github.io/grails-doc/2.4.x/guide/upgradingFrom23.html
If you are using Eclipse, go to Java build path, Order and Export, tick all the libraries and then execute the application

How To Run Grails 2.4.1 With Servlet 2.5

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.

ClassNotFoundException: SimpleKeyGenerator upgrading to Grails 2.4.0.RC1

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.

ClassCircularityError with grails 2.1 in debug mode

Since upgrading an app from grails 1.3.7 to 2.1.0 I am getting the error below when attempting to submit(post) forms.
It only happens in debug mode though!
I'm using Groovy/Grails Tool Suite 3.1.0
5:41:13 ERROR [GrailsExceptionResolver] ClassCircularityError occurred when processing request: [POST] /myapp/contextRoot/addItem - parameters:
startTimeDate:
addcoupon: Add Item
maxRedemptions:
timeZone: Europe/London
termsAndConditions:
percentOff:
title: test
buyX:
discountType:
shortDescription:
redemptionType.id:
getY:
categoryKey:
amountOff:
org/springframework/beans/PropertyBatchUpdateException. Stacktrace follows:
org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Executing action [addItem] of controller [com.mastercard.deals.merchant.testController] caused exception: Runtime error executing action
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: org.codehaus.groovy.grails.web.servlet.mvc.exceptions.ControllerExecutionException: Runtime error executing action
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
... 3 more
Caused by: java.lang.ClassCircularityError: org/springframework/beans/PropertyBatchUpdateException
... 3 more
I'm baffled as to why this is happening...any ideas?
Thanks
So the following JIRA appears similar to the issue:
I now run the app with -noreloading argument in debug mode and it works:
-grails-debug -noreloading -Dserver.port=8082 run-app

Resources