This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 9291
    
  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: 9291
    
  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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting $Proxy0 cannot be cast exception
 
Similar Threads
Error while calling EJB with client code
Some help required for understanding spring lifecycle
How do I know if transaction is configured successfully?
Session closed exception
JMS implementation using JNDI in spring application