1

When executing a spring program,the below exception is thrown:

Sep 09, 2015 9:16:00 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1099f62: startup date [Wed Sep 09 21:16:00 IST 2015]; root of context hierarchy Sep 09, 2015 9:16:00 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [applicationContext.xml] Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181) at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217) at .... org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at Application.main(Application.java:11) Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource at org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors(AnnotationConfigUtils.java:140) at org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser.parse(AnnotationConfigBeanDefinitionParser.java:47) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:174) ... 14 more Caused by: java.lang.ClassNotFoundException: org.springframework.aop.TargetSource at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) ... 24 more 

The spring configuration is as below:

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <context:annotation-config/> <context:component-scan base-package="com.test"/> </beans> 

I am unable to know how to resolve this issue. Please let me know any jar needs to be added to resolve this issue.

4
  • possible duplicate of Why/How am I getting the error: NoClassDefFoundError: org/springframework/aop/framework/ProxyFactory Commented Sep 9, 2015 at 17:32
  • I was able resolve the issue when i add the spring-aop-2.5.6.jar in the Referenced Libraries. Thanks for the possible solution!!It helped:) Commented Sep 13, 2015 at 6:03
  • "I was able resolve the issue when i add the spring-aop-2.5.6.jar in the Referenced Libraries." Your words solved my problem, thank you very much Commented May 10, 2017 at 5:57
  • @tiankonghewo: Please upvote my above comment if it has helped you. It would be useful to others as well, who are facing the same/similar issue. Commented Jun 23, 2017 at 4:24

3 Answers 3

2
nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource 

can't you see this error message?

you need org.springframework.aop package

add your spring-aop-x.x.x.jar to solve the problem.

Sign up to request clarification or add additional context in comments.

Comments

0

@Horizon_Net, I was also able to resolve the issue by adding spring-aop-4.3.3.jar to my spring library folder. Thanks @keshav-pradeep-ramanath!

1 Comment

Please upvote my above comment if it has helped you. It would be useful to others as well, who are facing the same/similar issue.
0

I was shading my self-contained jar to save space, and after upgrading to spring-context 4.3.4 (spring-context is dependent of spring-aop) from 3.2.6, I started having this problem. So what I had to do was to add it as a include-filter configuration in my maven-shade-plugin.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.