grails-plugins/grails-audit-logging-plugin

error with Grails 3.2.7+ with database-migration plugin 3.0.0

Closed this issue · 6 comments

I recently upgraded an app from 3.0.17 to 3.2.7, and when I run 'dbmupdate' or any related commands I get the following error below. I am on the latest 2.0.4 of this plugin as well.


APPLICATION FAILED TO START


Description:

The dependencies of some of the beans in the application context form a cycle:

requestMappingHandlerMapping defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration

grailsInterceptorMappedInterceptor

(inner bean)#1ae42ea1

restUsersWithSiteSlugInterceptor

grailsLinkGenerator (field private org.grails.datastore.mapping.model.MappingContext org.grails.web.mapping.DefaultLinkGenerator.mappingContext)
┌─────┐
| hibernateDatastore
↑ ↓
| auditLogListener
└─────┘

Context failed to load: Error creating bean with name 'requestMappingHandlerMapping' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsInterceptorMappedInterceptor': Cannot create inner bean '(inner bean)#1ae42ea1' of type [org.grails.plugins.web.interceptors.GrailsInterceptorHandlerInterceptorAdapter] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#1ae42ea1': Unsatisfied dependency expressed through method 'setInterceptors' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restUsersWithSiteSlugInterceptor': Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'grailsLinkGenerator': Unsatisfied dependency expressed through field 'mappingContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditLogListener': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'hibernateDatastore': Requested bean is currently in creation: Is there an unresolvable circular reference?
:dbmUpdate FAILED

a little more info.. we're overriding the bean and making a reference to hibernateDatastore like so:
auditLogListener(AuditLogListener, ref('hibernateDatastore')) { } which I think causes the issue.

In the Plugin descriptor, we instantiate the AuditLogListener for each datastore and do not take already created ones into account. So I think we need to check if such a listener already exists and skip in this case. Is your application using several datastores and you do not want to have the listener registered on all of them? If thats the case, can you please try to use the auditLog.disabled = true config key on the ones you do not want to have registered?

Any news on this?

We only have 1 data store. Interestingly enough, running the grails app by itself works. But running 'dbmUpdate' on the migration plugin gets the errors. I suspect it's setting up another datasource on the fly while the db migration plugin fires up perhaps?

Seems to be a known issue in grails/grails-data-mapping#946

See also grails/grails-database-migration#127

Closing it here.