wood burning stoves 2.0*
The moose likes Spring and the fly likes getting $Proxy0 cannot be cast exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "getting $Proxy0 cannot be cast exception" Watch "getting $Proxy0 cannot be cast exception" New topic
Author

getting $Proxy0 cannot be cast exception

sirisha mullapudi
Greenhorn

Joined: Mar 05, 2008
Posts: 8
Hi,
I have implemented BeanNameAware Interface and i am trying to access the bean using ApplicationContext.There i am getting exception $Proxy0 cannot be cast to net.springtest.SimpleBean. I am new to Spring framework.I have read that applicationcontext provides all the features that bean factory has.But here i am able to load the bean using BeanFactory but not ApplicationContext. Can you please describe what exactly proxy meant here and in what situations we should use bean factory and applicationContext. Appreciate your Help.

Regards,
Sireesha
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

You must be using some sort of AOP I think so you are getting a proxy object. Can you show us your spring configuration file...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
sirisha mullapudi
Greenhorn

Joined: Mar 05, 2008
Posts: 8
hi,please find the xml below :

Thanks,
Sireesha
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Yes indeed you are using AOP. In that case you'll have to create a base interface of SimpleBean class and use that interface as reference when you get the simpleBean from ApplicationContext...
 
Don't get me started about those stupid light bulbs.
 
subject: getting $Proxy0 cannot be cast exception