May 30th, 2008, 04:29 AM
Missing beans BeanNameAutoProxyCreator/BeanPostProcessor?
I have a strange behaviour with the BeanNameAutoProxyCreator/BeanPostProcessor.
bean1, bean2, etc. are advised successfully by advisors (through BeanNameAutoProxyCreator).
Project B (Web application):
This project uses project A packed as a JAR file. Included are the spring configs for bean1, bean2 and the advisors in the JAR.
Now what happens when running Project B is that bean1 is being advised as expected, but bean2 is not advised.
Looking at the log statements of BeanNameAutoProxyCreator, I discovered that a number of beans of Project A are obviously missing/na when the BeanNameAutoProxyCreator is trying to find matches.
Running the web application however, bean2 is available BUT NOT advised.
Testing further with a simple BeanPostProcessor that simply sysouts all bean names, again several beans of Project A are not going through the bean post processor.
Code and setting-wise, bean1 and bean2 are of the same type - is there anything or any code that blocks beans to be passed to the BeanPostProcessor/BeanNameAutoProxyCreator that I am not aware of? Or is it true that ALL beans (if everything works fine) are passed to a BeanNameAutoProxyCreator?
May 30th, 2008, 05:47 AM
Digging around for several hours, I found the cause of this behaviour.
In our Projects we usually use the @Transactional annotation.
There was an exception and one of our services in Project A used the TransactionProxyFactoryBean.
bean2 and all other missing beans were referenced by this evil service and weren't visible in BeanPostProcessor.
Replacing this service in Project A with @Transactional solved my problem.
Thanks for taking your time ;-)
Tags for this Thread