On a grails progect I want to build a binary plugin with “hook” implementable on each specific project
Binary plugin structure
MyService (service) MyHookClassInterface myHookClass MyHookServiceInterface myHookService MyHookClassInterface (interface) MyHookServiceInterface (interface)
Main project structure
ProjectHookClass impements MyHookClassInterface (groovy class)
ProjectHookService impements MyHookServiceInterface (service)
resources.groovy
beans = {
myHookClassInterface(ProjectHookClass)
myHookServiceInterface(ProjectHookService)
}
The solution works like a charm using source plugin but doesn’t inject MyService dependences in binary mode.
I also started the grails console and ctx.getBean(‘myHookClassInterface’) returns:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myHookClassInterface' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:269)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at org.springframework.beans.factory.BeanFactory$getBean.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at ConsoleScript0.run(ConsoleScript0:1)
thx
Fabio
solved: the issue was related to the presence of resources.groovy on the binary plugin. In this case grails startup process is not able to merge plugin and project resources.groovy. If you can it’s enough do delete the plugin’s resources.groovy.