-
Jan 18th, 2011, 02:31 AM
#1
Autowiring problem in spring integration
Hallo all.
I have a strange issue. I spent all the day yesterday but I didn't find the solution.
I'm using spring framework 3.05, integration 2.0. The application is an enterprise application divided in several modules.
The problem is in the integration module.
In this module I have several classes (activators, filters, interceptors).
All of them use the autowiring to access to the dao layer.
Here are two examples:
public class EventMessagePersisterInterceptor extends ChannelInterceptorAdapter {
private final static Logger logger = LoggerFactory.getLogger(EventMessagePersisterInter ceptor.class);
@Autowired
@Qualifier("eventMessageDao")
private GenericDao<OnlineEventMessage<?>, Long> eventMessageDao;
public class ReimpiantoContrattoActivator {
private final static Logger logger = LoggerFactory.getLogger(ReimpiantoContrattoActivat or.class);
@Autowired
@Qualifier("eventMessageDao")
private GenericDao<OnlineEventMessage<?>, Long> eventMessageDao;
Nothing of special, and all work fine.
This is an extract of the spring log when it creates all the bean and autowire what is needed.
Here the log of spring in the correct situation
2011-01-18 08:54:01,140 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'log4jInitialization'
2011-01-18 08:54:01,156 DEBUG [DefaultListableBeanFactory] Creating shared instance of singleton bean 'eventMessageDao'
2011-01-18 08:54:01,156 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'eventMessageDao'
....
2011-01-18 09:24:59,187 DEBUG [DefaultListableBeanFactory] Invoking afterPropertiesSet() on bean with name 'eventMessageDao'
2011-01-18 09:24:59,187 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'eventMessageDao'
2011-01-18 09:24:59,187 DEBUG [AutowiredAnnotationBeanPostProcessor] Autowiring by type from bean name 'onlineEventMessagePersisterInterceptor' to bean named 'eventMessageDao'
2011-01-18 09:24:59,187 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'onlineEventMessagePersisterInterceptor'
.....
As you can see the autowiring on that class is made correctly.
The problem happens when I import two project descriptor from which I depend on. They are others custom projects.
The problem I think is in this class
public class ToXmlBuilder implements BeanFactoryPostProcessor {
...
/**
* @see org.springframework.beans.factory.config.BeanFacto ryPostProcessor#postProcessBeanFactory(org.springf ramework.beans.factory.config.ConfigurableListable BeanFactory)
*/
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFac tory beanFactory) throws BeansException {
OxMapper oxMapper = beanFactory.getBean(OxMapper.class);
ToXmlBuilder.setOxMapper(oxMapper);
}
...
When I import them the autowiring on some of my classes do not work any more.
And this is an extract of the wrong situation.
2011-01-18 09:00:19,562 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'log4jInitialization'
2011-01-18 09:00:19,578 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'oxMapper'
2011-01-18 09:00:19,593 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'oxMapper'
2011-01-18 09:00:19,609 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'eventMessageParser'
2011-01-18 09:00:19,609 DEBUG [DefaultListableBeanFactory] Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAu towiredAnnotationProcessor'
2011-01-18 09:00:19,609 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'org.springframework.context.annotation.internalAu towiredAnnotationProcessor'
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Eagerly caching bean 'org.springframework.context.annotation.internalAu towiredAnnotationProcessor' to allow for resolving potential circular references
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'org.springframework.context.annotation.internalAu towiredAnnotationProcessor'
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Creating shared instance of singleton bean 'org.springframework.context.annotation.internalRe quiredAnnotationProcessor'
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Creating instance of bean 'org.springframework.context.annotation.internalRe quiredAnnotationProcessor'
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Eagerly caching bean 'org.springframework.context.annotation.internalRe quiredAnnotationProcessor' to allow for resolving potential circular references
2011-01-18 09:00:19,625 DEBUG [DefaultListableBeanFactory] Finished creating instance of bean 'org.springframework.context.annotation.internalRe quiredAnnotationProcessor'
...
2011-01-18 09:25:06,453 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'eventMessageDao'
2011-01-18 09:25:06,453 DEBUG [AutowiredAnnotationBeanPostProcessor] Autowiring by type from bean name 'onlineReimpiantoContrattoActivator' to bean named 'eventMessageDao'
As you can see the eventMessageDao is present and is autowired on all of the other class of the same module, but no more on the interceptor.
Any idea.
Kind regards
Massimo
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules