2
votes

I am using the newest STS, just updated:\ Version: 2.9.0.RELEASE Build Id: 201203011000

I have downloaded spring-framework-3.1.1.RELEASE into a directory. I created a new Spring project. If the main() contains only a System.out.println() it's working fine with no problem.

I made a lib/ dir in my project and imported all the libs from the Spring Framework. I also imported commons-logging-1.1.1.jar

But if I add: ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");

When I run the app it throws: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

I printed out the class path from main(): System.out.println(System.getProperty("java.class.path")); And I can see the commons-logging-1.1.1.jar on it since I added it.

If I make in main(): org.apache.commons.logging.LogFactory lf; it has no problem at all, code completion is working fine also.

What should I check?

1

1 Answers

1
votes

OK, my bad.

I did not import the Spring jars into the project, just added them as User library. As I imported them and added explicitly to the class path everything just went fine.