Hey.
I have a class which implements the InitializingBean and DisposableBean Interfaces to trigger the Install/Uninstall Event of the plugin.
I want to generate a few Entitys in my ActiveObject Database when the plugin will be installed. In my afterPropertSet() Function I use a component which I wrote.
@Component
public class EmailTemplateManagerImpl implements EmailTemplateManager {
AOMainService aoMainService;
...
public void doSomething() {
aoMainService.createEntity();
}
}
Here is my ActiveObjects service implementation
@Component
public class AOMainServiceImpl implements AOMainService {
@ComponentImport
private ActiveObjects ao;
@Autowired
public AOMainServiceImpl(final ActiveObjects ao) {
this.ao = ao;
}
public void createEntity() {
final MyEntity entity = ao.create(MyEntity.class);
...
entity.save();
}
And finally my class with the InitializingBean & DisposableBean interfaces.
@Component
public class PluginListener implements InitializingBean, DisposableBean {
private EmailTemplateManager emailTemplateManager;
@Autowired
public PluginListener(final EmailTemplateManager emailTemplateManager){
this.emailTemplateManager = emailTemplateManager;
}
@Override
public void afterPropertiesSet() throws Exception {
emailTemplateManager.doSomething();
}
When I debug the afterPropertiesSet I can see that all components are injected and not null!
But when activeobjects get called I got the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginListener': Invocation of init method failed; nested exception is java.lang.IllegalStateException: plugin [{de.scag.jira.plugin.mailhandler}] invoking ActiveObjects before <ao> configuration module is enabled or plugin is missing an <ao> configuration module. Note that scanning of entities from the ao.model package is no longer supported.
jira73x_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
jira73x_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
jira73x_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
jira73x_1 | at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
jira73x_1 | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
jira73x_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
jira73x_1 | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
jira73x_1 | at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
jira73x_1 | at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
jira73x_1 | at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:60)
jira73x_1 | at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:325)
jira73x_1 | at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
jira73x_1 | at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:290)
jira73x_1 | at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
jira73x_1 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
jira73x_1 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
jira73x_1 | at java.lang.Thread.run(Thread.java:748)
jira73x_1 | Caused by: java.lang.IllegalStateException: plugin [{de.scag.jira.plugin.mailhandler}] invoking ActiveObjects before <ao> configuration module is enabled or plugin is missing an <ao> configuration module. Note that scanning of entities from the ao.model package is no longer supported.
jira73x_1 | at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.delegate(TenantAwareActiveObjects.java:165)
jira73x_1 | at com.atlassian.activeobjects.osgi.TenantAwareActiveObjects.create(TenantAwareActiveObjects.java:266)
jira73x_1 | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
jira73x_1 | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
jira73x_1 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
jira73x_1 | at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
jira73x_1 | at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
jira73x_1 | at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
jira73x_1 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
jira73x_1 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
jira73x_1 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
jira73x_1 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
jira73x_1 | at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
jira73x_1 | at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
jira73x_1 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
jira73x_1 | at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
jira73x_1 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
jira73x_1 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
jira73x_1 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
jira73x_1 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
jira73x_1 | at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
jira73x_1 | at com.sun.proxy.$Proxy3186.create(Unknown Source)
jira73x_1 | at de.scag.jira.plugin.mailhandler.ao.impl.AOMainServiceImpl.createEmailTemplate(AOMainServiceImpl.java:145)
jira73x_1 | at de.scag.jira.plugin.mailhandler.template.impl.EmailTemplateManagerImpl.installTemplate(EmailTemplateManagerImpl.java:158)
jira73x_1 | at de.scag.jira.plugin.mailhandler.template.impl.EmailTemplateManagerImpl.installDefaultTemplate(EmailTemplateManagerImpl.java:144)
jira73x_1 | at de.scag.jira.plugin.mailhandler.PluginListener.afterPropertiesSet(PluginListener.java:34)
jira73x_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
jira73x_1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
jira73x_1 | ... 16 more```
Before I implemented the InitializingBean & DisposableBean activeobjects was working just fine...
My Question right now:
**What do I have to consider when I implement the afterPropertieSet Function with activeobecjts?!**
Regards