ClassCircularityError with grails 2.1 in debug mode - grails

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

Related

java.lang.IllegalStateException: Either class [coconut.User] is not a domain class or

So I'm getting this error. I'm sure it has something to do with incompatible versions of stuff, but I have no idea what I did wrong.
I'm doing it through sdkman as I should be... grails --version gives me 3.2.11.
2017-06-29 22:17:15.406 ERROR --- [nio-8080-exec-1] o.g.web.errors.GrailsExceptionResolver : IllegalStateException occurred when processing request: [GET] /user
Either class [coconut.User] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Either class [coconut.User] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
at org.grails.datastore.gorm.GormEnhancer.stateException(GormEnhancer.groovy:427)
at org.grails.datastore.gorm.GormEnhancer.findStaticApi(GormEnhancer.groovy:296)
at org.grails.datastore.gorm.GormEnhancer.findStaticApi(GormEnhancer.groovy:292)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.currentGormStaticApi(GormEntity.groovy:1341)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.getCount(GormEntity.groovy:627)
at coconut.UserController.create(UserController.groovy:5)
... 14 common frames omitted
Steps to Reproduce
Download the ziped project below.
grails clean; grails run-app
And in a second terminal: curl localhost:8080/user
Expected Behaviour
I don't get that error.
Actual Behaviour
I get that error.
Environment Information
Operating System: Ubuntu 17.04
Grails Version: 3.2.11
JDK Version: 1.8.0_131
Example Application
coconut-test.zip
Put:
compile "org.grails.plugins:hibernate5"
into your "dependencies" block in build.gradle

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/**")
}
}

Grails 3.0.3, Error running intrgration test using test-app

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?

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.

Grails test war when deployed in tomcat gives ERROR

Even after increasing heap size I get Perm Gen and also the following error.
I get first the following and after repeated attempts to access my application I get Perm Gen
JDK: 1.6
Grails : 2.0.0
Tomcat 7
I have no clue how to resolve.
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is java.lang.VerifyError: (class: org/codehaus/groovy/runtime/InvokerInvocationException, method: getMessage signature: ()Ljava/lang/String;) Illegal constant pool index
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:118)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
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: java.lang.VerifyError: (class: org/codehaus/groovy/runtime/InvokerInvocationException, method: getMessage signature: ()Ljava/lang/String;) Illegal constant pool index
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:97)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:884)
at groovy.lang.Closure.call(Closure.java:410)
at org.codehaus.groovy.grails.plugins.DefaultGrailsPlugin.doWithApplicationContext(DefaultGrailsPlugin.java:489)
at org.codehaus.groovy.grails.plugins.AbstractGrailsPluginManager.doPostProcessing(AbstractGrailsPluginManager.java:169)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.performPostProcessing(GrailsRuntimeConfigurator.java:232)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:172)
at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:124)
at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:121)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:104)
... 9 more
You're getting a VerifyError which means you problem is most likely a classpath problem, or you compiled using a different Java version to what you are running under.

Resources