Spring出现Unexpected exception parsing XML document from class path resource [applicationBeans.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource异常

  在自学Spring4的过程中,遇到了棘手的异常,一直找不到问题所在,后来经过对每个过程进行逐一排查之后,发现少了一个jar包:spring-aop-4.0.0.RELEASE.jar。完整的异常信息如下:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationBeans.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.wyb.spring.beans.annotation.Main.main(Main.java:13)
Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource
    at org.springframework.context.annotation.AnnotationConfigUtils.registerAnnotationConfigProcessors(AnnotationConfigUtils.java:194)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.registerComponents(ComponentScanBeanDefinitionParser.java:150)
    at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:86)
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1424)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1414)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:141)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    ... 14 more
Caused by: java.lang.ClassNotFoundException: org.springframework.aop.TargetSource
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 25 more

  把该jar包导入进去之后,异常解决,编程通过。

时间:2016-03-20 12:32:39

时间: 2024-10-25 04:17:52

Spring出现Unexpected exception parsing XML document from class path resource [applicationBeans.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource异常的相关文章

parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not e

控制台异常: parsing XML document from class path resource [applicationtext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationtext.xml] cannot be opened because it does not exist 报错原因是 xml名字可能写错了 原文地址:https://www.cnbl

Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException:

今天在把自己的项目转为maven架构的时候,居然碰到了一个很奇葩的问题具体如下: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 23 in XML document from class path resource [spring-mvc.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cos-all-l

Java AOP nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice || Error creating bean with name &#39;org.springframework.aop.aspectj.AspectJPointcutAdvisor#0&#39; 两个异常解决办法

贴出applicationContext.xml <?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://ww

spring报错 org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [cn/itcast/b_anno/bean.xml]; nested exception is java.lang.

这次遇到的错是在 使用注解的方式 来使用事务的时候 在配置文件中配置了 但是却没有使用 补充:没有aop相关的包也会报这个错,需要加上aop的包 解决:在配置文件中将事务有关的配置移除了然后就好了          额,看来在配置文件中的东西一定注意啊,需要使用的时候才去进行配置,不要多配置也不要少配置

spring项目启动错误——java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext

最近在搭spring项目框架的时候,遇到一个很伤的问题,翻了很多帖,都报告说什么少spring-context包啊之类的,但实际上spring的那些依赖我根本没漏,下面是我的pom: <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version

Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError:org/springframework/beans/factory/config/EmbeddedValueResoler

我是在运行一个spring-mybatis小案例时遇到这个错误,已经解决,在这里记录和分享给你们 报错截图如下: 解决方法:检查发现spring的核心包spring-bean版本和其他核心包版本不同,更改为和其他核心包相同的版本即可 这类报错引起的原因还有一些,这只是一种解决方法供参考! 原文地址:https://www.cnblogs.com/quanbin/p/11100337.html

FreeMarker与Spring MVC 4结合错误:Caused by: java.lang.NoClassDefFoundError: org/springframework/ui/freemarker/FreeMarkerConfiguration

添加spring-context-support的依赖到POM: <!-- spring-context-support --> <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support --> <dependency> <groupId>org.springframework</groupId> <artifactId>spr

Exception in thread &quot;main&quot; java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean

异常信息 2017-09-02 18:06:37.223 [main] ERROR o.s.boot.SpringApplication - Application startup failed java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$Endpoint

使用Spring data Jpa 时遇到 java.lang.ClassNotFoundException: org.springframework.core.ReactiveTypeDescriptor

背景 原本项目是使用SSM+Maven进行开发,而后想同时使用Jpa(即mybatis和jpa混用),配置好相关文件后,使用Junit做测试时,出现以下错误. 主要: ERROR - Caught exception while allowing TestExecutionListener [org.springframewor[email protected]29774679] to prepare test instance [[email protected]]java.lang.Ille