Joko
Joko

Reputation: 176

ClassNotFoundException at Spring Bean Injection

I have a Spring beans.xml that specifies a certain class my.package.Class to be injected somewhere in my code by Autowiring. The program is actually a web application inside a Tomcat container. Now when I launch Tomcat the logfile tells me my.package.Class cannot be found, even though its JAR is both in the classpath and the web application's lib/ directory. Do I have to tell Tomcat or Spring where to find the JAR, too, and if so: how?

Upvotes: 1

Views: 5873

Answers (1)

user
user

Reputation: 3088

Make sure, you have this code in your context:

<context:annotation-config />
<context:component-scan base-package="package.autowire.context" />

For more info you better read http://springindepth.com/book/in-depth-ioc-autowiring.html

By the way, check the default output folder in your project build path. That could also be the cause.

Upvotes: 3

Related Questions