Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (7k points)

I am executing a simple Dependency Injection program of spring and getting this exception. I have already included common-logging1.1.1.jar  and spring.jar files. Can someone help me out?

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119)

    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)

    at com.client.StoryReader.main(StoryReader.java:15)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    ... 6 more

1 Answer

0 votes
by (13.1k points)

If you are using maven for managing dependencies, add the following to your pom.xml file:

<dependency>

        <groupId>commons-logging</groupId>

        <artifactId>commons-logging</artifactId>

        <version>1.1.1</version>

</dependency>

Want to learn Java? Check out the core Java certification from Intellipaat.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...