File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring error when injecting beans

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a Spring web application in which I inject some beans on my action class. When I run my app in Tomcat, I get the following exception:


From where did the $Proxy20 come from?

 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright! Got rid of this one as well. I was not implementing an interface in one of my bean that I was injecting in my facade layer.
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep Spring creates DynamicProxy objects when it needs to add functionality to your code, and to create a DynamicProxy, you class has to implement an interface because you pass the interface class to the constructor of a DynamicProxy. This way from the client calling code perspective, it has a class that implements your interface.

There is another work around, but always create interfaces anyway, it is great Java coding best practice.

But if you include CGLib's jar file in your class path then Spring will be able to create Proxy objects in which the Proxy extends your class.

Mark
 
Joe Harry
Ranch Hand
Posts: 10045
3
Eclipse IDE Mac PPC Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we just did implement a dynamic dispatching proxy for one of our business requirements and together with this exception, things became much more clearer to me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic