Grails
  1. Grails
  2. GRAILS-7342

BeanBuilder used by resources.groovy is not able to access bean definitions created by plugins (or Hibernate plugin is not calling GrailsRuntimeConfigurator.reset)

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Patch Submitted:
      Yes

      Description

      Apparently, from the beanBuilder used in
      resources.groovy, i can't access the bean definitions present in the
      beanBuilder of the plugins (app and plugins don't share
      the same RuntimeSpringConfiguration). So i cannot redefine the beanClass of a
      specific beanDefinition.

      ====

      The below source code snippets produce different results proving they aren't sharing the same RuntimeSpringConfiguration.

      Inside a plugin:

      ++++++++++++++++++++++++
      +++ TestGrailsPlugin.groovy +++
      ++++++++++++++++++++++++

      def doWithSpring = {
      println "== doWithSpring =="
      delegate.getBeanDefinitions().each

      { beanDef -> println beanDef.key }

      }

      Inside an application:

      ++++++++++++++++++++++++
      +++ resources.groovy +++
      ++++++++++++++++++++++++

      beans = {
      println "== beans =="
      delegate.getBeanDefinitions().each

      { beanDef -> println beanDef.key }

      }

      ====

      Analyzing the source code, the problematic call stack is:

      https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java#L151

      https://github.com/grails/grails-core/blob/master/grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/plugins/orm/hibernate/HibernatePluginSupport.groovy#L113

      https://github.com/grails/grails-core/blob/master/grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/plugins/orm/hibernate/HibernatePluginSupport.groovy#L1047

      Hibernate plugin is calling GrailsRuntimeConfigurator.loadExternalSpringConfig which initializes springGroovyResourcesBeanBuilder with a different RuntimeSpringConfiguration.

      So, when GrailsRuntimeConfigurator.doPostResourceConfiguration is called, springGroovyResourcesBeanBuilder is non-null

      https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java#L157

      https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java#L323

      Should Hibernate plugin call GrailsRuntimeConfigurator.reset?

      https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/spring/GrailsRuntimeConfigurator.java#L383

      ====

      Read this in the context:

      http://grails.1312388.n4.nabble.com/Initialization-of-springGroovyResourcesBeanBuilder-GrailsRuntimeConfigurator-in-HibernatePluginSuppot-td3330732.html#a3332445

      http://grails.1312388.n4.nabble.com/plugin-vs-application-doWithSpring-resources-groovy-and-getBeanDefinitions-td3328911.html#a3329812

      ===

      Thanks.

      1. GrailsRuntimeConfigurator.patch
        0.5 kB
        Daniel Henrique Alves Lima
      2. HibernatePluginSupport.patch
        1.0 kB
        Daniel Henrique Alves Lima

        Activity

        Hide
        Daniel Henrique Alves Lima added a comment - - edited

        Patch files generated using "diff -u base_file modified_file".
        Grails 1.3.6 was used as base.

        Show
        Daniel Henrique Alves Lima added a comment - - edited Patch files generated using "diff -u base_file modified_file". Grails 1.3.6 was used as base.
        Hide
        Daniel Henrique Alves Lima added a comment - - edited

        @@@@@@@@@@@@@@@@
        @@@@ BEFORE @@@@
        @@@@@@@@@@@@@@@@
        Running Grails application..
        == doWithSpring ==
        localeChangeInterceptor
        dataSource
        messageSource
        org.springframework.aop.config.internalAutoProxyCreator
        grailsApplicationPostProcessor
        customEditors
        grailsUrlMappingsHolder
        localeResolver
        dataSourceUnproxied
        classLoader
        filterInterceptor
        grailsUrlMappingsHolderBean
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters
        proxyHandler
        shutdownHook
        urlMappingsTargetSource
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass
        pluginManagerPostProcessor
        transactionManagerPostProcessor
        == beans ==

        @@@@@@@@@@@@@@@
        @@@@ AFTER @@@@
        @@@@@@@@@@@@@@@

        Running Grails application..
        == doWithSpring ==
        org.codehaus.groovy.grails.plugins.web.taglib.CountryTagLib
        localeChangeInterceptor
        messageSource
        org.codehaus.groovy.grails.plugins.web.taglib.PluginTagLib
        customEditors
        grailsApplicationPostProcessor
        groovyPagesTemplateEngine
        classLoader
        groovyPageResourceLoader
        groovyPagesUriService
        org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters
        shutdownHook
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass
        pluginManagerPostProcessor
        org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib
        gspTagLibraryLookup
        org.springframework.aop.config.internalAutoProxyCreator
        jspTagLibraryResolver
        org.codehaus.groovy.grails.plugins.web.taglib.FormatTagLib
        org.codehaus.groovy.grails.plugins.web.taglib.FormTagLib
        localeResolver
        org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib
        filterInterceptor
        org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib
        proxyHandler
        jspViewResolver
        org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib
        == beans ==
        == beans ==
        viewNameTranslator
        errorsXmlMarshallerRegisterer
        localeChangeInterceptor
        grailsApplicationPostProcessor
        persistenceInterceptor
        classLoader
        groovyPagesUriService
        org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib
        xmlParsingParameterCreationListener
        dialectDetector
        openSessionInViewInterceptor
        jspTagLibraryResolver
        org.codehaus.groovy.grails.plugins.web.taglib.FormatTagLib
        entityInterceptor
        org.codehaus.groovy.grails.plugins.web.taglib.FormTagLib
        grailsUrlMappingsHolder
        transactionManager
        localeResolver
        org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib
        controllerHandlerMappings
        grailsUrlMappingsHolderBean
        proxyHandler
        convertersConfigurationInitializer
        transactionManagerPostProcessor
        org.codehaus.groovy.grails.plugins.web.taglib.CountryTagLib
        sessionFactory
        dataSource
        hibernateProperties
        scaffoldedActionMap
        simpleControllerHandlerAdapter
        annotationHandlerAdapter
        org.codehaus.groovy.grails.plugins.web.taglib.PluginTagLib
        messageSource
        customEditors
        groovyPagesTemplateEngine
        annotationHandlerMapping
        dataSourceUnproxied
        jsonParsingParameterCreationListener
        groovyPageResourceLoader
        jsonErrorsMarshaller
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters
        flushingRedirectEventListener
        shutdownHook
        multipartResolver
        scaffoldingTemplateGenerator
        exceptionHandler
        org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass
        pluginManagerPostProcessor
        org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib
        lobHandlerDetector
        controllerToScaffoldedDomainClassMap
        gspTagLibraryLookup
        org.springframework.aop.config.internalAutoProxyCreator
        errorsJsonMarshallerRegisterer
        hibernateEventListeners
        filterInterceptor
        org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib
        nativeJdbcExtractor
        urlMappingsTargetSource
        mainSimpleController
        eventTriggeringInterceptor
        xmlErrorsMarshaller
        org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib
        jspViewResolver

        Show
        Daniel Henrique Alves Lima added a comment - - edited @@@@@@@@@@@@@@@@ @@@@ BEFORE @@@@ @@@@@@@@@@@@@@@@ Running Grails application.. == doWithSpring == localeChangeInterceptor dataSource messageSource org.springframework.aop.config.internalAutoProxyCreator grailsApplicationPostProcessor customEditors grailsUrlMappingsHolder localeResolver dataSourceUnproxied classLoader filterInterceptor grailsUrlMappingsHolderBean org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters proxyHandler shutdownHook urlMappingsTargetSource org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass pluginManagerPostProcessor transactionManagerPostProcessor == beans == @@@@@@@@@@@@@@@ @@@@ AFTER @@@@ @@@@@@@@@@@@@@@ Running Grails application.. == doWithSpring == org.codehaus.groovy.grails.plugins.web.taglib.CountryTagLib localeChangeInterceptor messageSource org.codehaus.groovy.grails.plugins.web.taglib.PluginTagLib customEditors grailsApplicationPostProcessor groovyPagesTemplateEngine classLoader groovyPageResourceLoader groovyPagesUriService org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters shutdownHook org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass pluginManagerPostProcessor org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib gspTagLibraryLookup org.springframework.aop.config.internalAutoProxyCreator jspTagLibraryResolver org.codehaus.groovy.grails.plugins.web.taglib.FormatTagLib org.codehaus.groovy.grails.plugins.web.taglib.FormTagLib localeResolver org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib filterInterceptor org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib proxyHandler jspViewResolver org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib == beans == == beans == viewNameTranslator errorsXmlMarshallerRegisterer localeChangeInterceptor grailsApplicationPostProcessor persistenceInterceptor classLoader groovyPagesUriService org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib xmlParsingParameterCreationListener dialectDetector openSessionInViewInterceptor jspTagLibraryResolver org.codehaus.groovy.grails.plugins.web.taglib.FormatTagLib entityInterceptor org.codehaus.groovy.grails.plugins.web.taglib.FormTagLib grailsUrlMappingsHolder transactionManager localeResolver org.codehaus.groovy.grails.plugins.web.taglib.JavascriptTagLib controllerHandlerMappings grailsUrlMappingsHolderBean proxyHandler convertersConfigurationInitializer transactionManagerPostProcessor org.codehaus.groovy.grails.plugins.web.taglib.CountryTagLib sessionFactory dataSource hibernateProperties scaffoldedActionMap simpleControllerHandlerAdapter annotationHandlerAdapter org.codehaus.groovy.grails.plugins.web.taglib.PluginTagLib messageSource customEditors groovyPagesTemplateEngine annotationHandlerMapping dataSourceUnproxied jsonParsingParameterCreationListener groovyPageResourceLoader jsonErrorsMarshaller org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters flushingRedirectEventListener shutdownHook multipartResolver scaffoldingTemplateGenerator exceptionHandler org.codehaus.groovy.grails.web.filters.JavascriptLibraryFiltersClass pluginManagerPostProcessor org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib lobHandlerDetector controllerToScaffoldedDomainClassMap gspTagLibraryLookup org.springframework.aop.config.internalAutoProxyCreator errorsJsonMarshallerRegisterer hibernateEventListeners filterInterceptor org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib nativeJdbcExtractor urlMappingsTargetSource mainSimpleController eventTriggeringInterceptor xmlErrorsMarshaller org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib jspViewResolver

          People

          • Assignee:
            Unassigned
            Reporter:
            Daniel Henrique Alves Lima
          • Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development