File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Application Frameworks and the fly likes @Autowire is not working properly in my spring application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "@Autowire is not working properly in my spring application" Watch "@Autowire is not working properly in my spring application" New topic
Author

@Autowire is not working properly in my spring application

prathibha shiju
Greenhorn

Joined: Jun 19, 2007
Posts: 17
Hi
my service implementation class is marked as @Service and my controller class as @Controller,
and i have @Autowired
private FruitService fruitService; in my controller class. and getters and setters of the same. but when i try to acesss fruitService through getter methos i am getting classnotfound exception. can any body tell me what might have went wrong.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

If autowiring doesn't work, I'd expect a NullPointerException, as it means a property you were expecting to be set wasn't.

ClassNotFoundException is different than NullPointerException - it means there's a class referenced in your code that your web application can't find. This could be due to multiple things - a mis-spelling of a class name in a deployment descriptor or spring xml file, a packaging issue where the class doesn't get included in the deployment, or a classpath issue.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
prathibha shiju
Greenhorn

Joined: Jun 19, 2007
Posts: 17
yes that was nullpointer exception. but still i could not corre t that.
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

1. Have you enabled annotation configuration?



2. Do you have multiple beans that implement FruitService defined?
DZone article discussing multiple beans and autowiring problems.

3. You mentioned you have both the attribute and the getter/setter methods tagged with the @Autowire attribute... you should only need to do this in one or the other.

4. Are the parameters of the getter/setter methods and the attribute the same class?
 
Don't get me started about those stupid light bulbs.
 
subject: @Autowire is not working properly in my spring application
 
Similar Threads
Hibernate - using 'services'; is this consider a good design?
Spring Architecture help
Spring: Creating a servlet/controller to handle REST calls
Business Service
[AJAX] Web Application logical division