Home Grails: 3.3.2: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context
Reply: 1

Grails: 3.3.2: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context

49er
1#
49er Published in 2017-12-07 00:32:14Z

DO NOT MARK IT AS DUPLICATE I have just created a new Grails app. I have created a new domain class and a controller with a corresponding gsp view. I have added my jdbc connection details in application.yml. When i run it i get the below issue:

objc[27382]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java (0x107fcf4c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x1080bb4e0). One of the two will be used. Which one is undefined.
2017-12-07 15:14:06.838 ERROR --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' threw an exception

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4ebea12c: startup date [Thu Dec 07 15:14:02 PST 2017]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414)
        at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)
        at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
        at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:556)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:387)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:374)
        at grails.boot.GrailsApp$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
        at ice_grailsapp.Application.main(Application.groovy:8)

2017-12-07 15:14:06.843 ERROR --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'grailsApplicationPostProcessor' threw an exception

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4ebea12c: startup date [Thu Dec 07 15:14:02 PST 2017]; root of context hierarchy
        at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414)
        at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)
        at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
        at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:556)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:387)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:374)
        at grails.boot.GrailsApp$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
        at ice_grailsapp.Application.main(Application.groovy:8)

My build.gradle has all the default dependencies . I have just added the below dependency:

compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.13' compile group: 'cglib', name: 'cglib', version: '3.2.4' compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.8.RELEASE'

My domain class is named CUSTOMER.groovy

class CUSTOMER {

    String pk
    String SPN
    String CustomerPk

    static constraints = {
    }
}

My database is MYSQL and i am just trying to read from the table named CUSTOMER. Do i need to map each and every field in table in the domain class? kindy advice

49er
2#
49er Reply to 2017-12-11 22:40:44Z

Since i was new to grails i was finding it hard to understand this error. I later realized that the issue was with the GORM class. I was trying to connect to a existing SQL database and retrieve data from those tables. By default Grails tries to map verison(field) When Grails was trying to connect to the table it also tried mapping verion which were not present in the table. By specifying the id(primary key)of the table and also mentioning the verion as false. Helped me resolve the issue. The following is the change:

class CUSTOMER {

    String pk
    String spn
    String customerpk

    static mapping = {
        id name: 'customerpk'
        version false
        id generator: 'assigned'
    }

}

Also make sure that you mention the primary key of your table as id in the GORM class. Note: Sometimes the error message thrown will have some details in the end and looking at the first line will not always make sense.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302538 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO