Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Bug is Spring or meant to behave like that?

 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of my colleagues brought this up while he was practicing Spring 2.5 Knight example from Spring in Action.
While using AOP (the Minstrel example), if we use just the BeanFactory, we never get the log4j log messages.
Nor is there any error message etc. generated from Spring about why AOP did not work.
However, if we use ApplicationContext, those log messages are generated!
From a technical point of view, this seems fine because BeanFactory is the most basic container over which ApplicationContext is built.
Therefore, it may not be expected to support advanced concepts like AOP, transactions etc.
However, the absence of any error message from Spring can keep a newbie guessing for hours.
Submit a JIRA, shall I?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this. There's no error because AOP will not take effect. It's not a bug.
 
aditee sharma
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Christophe Verré wrote:Check this. There's no error because AOP will not take effect. It's not a bug.



I have already said that that AOP will not take effect is understood.
Thanks for your post, it is now clear that this is by design.
However, I don't understand why Spring chose to not throw an error/exception message when
somebody tries to make the BeanFactory work with AOP.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it is not a bug.

BeanFactory was created before AOP was introduced. BeanFactory does not have the lifecycle phase of BeanPostProcessesors, where the DynamicProxy objects are created for AOP, etc.

If they added AOP and this phase to BeanFactory, then it would break old code using BeanFactory, so to keep backwards compatibility it is better and easier to decorate the BeanFactory with the ApplicationContext.

You can't add exceptions or anything to BeanFactory or you would also break backwards compatibility.

Mark
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But even when I use ClassPathXmlApplicationContext, the minstrel message DOSE NOT show up !(I'm using spring 2.5)
I think the xml file may have something wrong:


Could you help me?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic