I've encountered strange behavior which I can't explain. I have a DAO class, defined as a normal Spring bean. I get an instance of it by caling ApplicationContext.getBean(). This worked fine until today, when I had the class implement a simple interface. Now I suddenly began getting class cast exceptions becaase the getBean() method returned an object of class $Proxy10 instead of the DAO class I had been expecting.
After some trial and error, I discovered the getBean() call returned the $Proxy10 object only when the class implemented the interface and had a method annotated as @Transactional. When I didn't implement the interface, or when I removed the @Transactional annotation, the getBean() method worked perfectly. But when I had both the interface implementation and the annotation, I got the dreaded $Proxy10 object.
I'm using Spring 2.5.6.
Anyone have any ideas what causes this?


Reply With Quote
