缺少jar包导致Spring利用注解的方式来实现AOP所出现的错误

原创 2016年08月28日 22:10:00

在利用AspectJ进行动态代理的时候,出现了如下的错误信息,这样的问题是由于缺少jar包引起的,缺少的jar包是struts的aopalliance-1.0.jar

我们从struts的包中,aopalliance-1.0.jar在如下文件夹中。


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.config.internalAutoProxyCreator': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:741)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.bjsxt.test.UserServiceTest.testAddUser(UserServiceTest.java:13)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004)
... 35 more
Caused by: java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
at org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry.<init>(DefaultAdvisorAdapterRegistry.java:49)
at org.springframework.aop.framework.adapter.GlobalAdvisorAdapterRegistry.<clinit>(GlobalAdvisorAdapterRegistry.java:32)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.<init>(AbstractAutoProxyCreator.java:115)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.<init>(AbstractAdvisorAutoProxyCreator.java:47)
at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.<init>(AspectJAwareAdvisorAutoProxyCreator.java:46)
at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.<init>(AnnotationAwareAspectJAutoProxyCreator.java:48)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 37 more
Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 48 more

版权声明:本文为博主原创文章,未经博主允许不得转载。

jar包中初始化Spring环境,报错找不到applicationContext.xml

注意:(1)ApplicationContext ctx=new ClassPathXmlApplicationContext()是从当前路径寻找,xml文件应在当前目录下。不过如果指定绝对路径也可以...
  • u013036792
  • u013036792
  • 2015年09月17日 16:42
  • 4841

spring一些常见缺少包的问题

Spring框架搭建遇到的问题汇总 1、The resource is not on the build path of a Java project   然后把相应的依赖加入构建路径 ...
  • a1286160028
  • a1286160028
  • 2017年03月25日 18:04
  • 249

spring容器被多次初始化问题排查及解决

由于spring多次初始化,导致资源被重复加载,多次初始化,会带来一系列问题...
  • cainiaodejiaobu
  • cainiaodejiaobu
  • 2017年08月04日 18:40
  • 788

缺少spring.jar包的低级错误

错误原因:缺少了spring-beans-3.2.0.RELEASE.jar等spring的一系列jar包    (由于引入组件扫描注解,这个spring-context-3.2.0.RELEAS...
  • hu996996
  • hu996996
  • 2017年07月27日 22:14
  • 328

Spring 注解学习

Spring以及其他分支框架注解开发,在学习和工作中总结的一小部分,希望能帮到大家...
  • sudiluo_java
  • sudiluo_java
  • 2016年07月08日 10:43
  • 6687

SpringCloud(六):Ribbon示例

基于博客已有的项目所做更改。 链接:http://pan.baidu.com/s/1bpnNvRL 密码:ffnl 一、建立ribbon的项目 将microservice-consumer-movi...
  • u013037201
  • u013037201
  • 2017年08月12日 15:21
  • 348

spring源码编译后缺少的jar包

将spring源码导入eclipse之后,会发现spring-core下缺少spring-cglib-repack-3.2.0.jar和spring-objenesis-repack-2.2.jar两...
  • andybbc
  • andybbc
  • 2016年10月29日 23:23
  • 1195

Spring容器初始化

一,容器初始化 1,在web.xml中配置ContextLoaderListener     这个监听器实现了ServletContextListener,这个接口有2个方法。     publ...
  • u011710466
  • u011710466
  • 2016年10月21日 23:36
  • 1532

使用CGLIB实现AOP功能与AOP概念解释

使用CGLIB实现AOP功能在Java里面,我们要产生某个对象的代理对象,这个对象必须要有一个特点,即这个对象必须实现一个接口,动态代理技术只能基于接口进行代理。有时候我们在做开发的时候,这个对象就没...
  • yerenyuan_pku
  • yerenyuan_pku
  • 2016年10月19日 22:38
  • 1637

spring3.0使用注解aop需要的jar包--及其流程

aopalliance.jar asm.jar cglib-2.1.3.jar aspectjrt.jar aspectjweaver.jar spring自身的包 jdk必须...
  • jintianhen1
  • jintianhen1
  • 2013年12月23日 15:51
  • 2750
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:缺少jar包导致Spring利用注解的方式来实现AOP所出现的错误
举报原因:
原因补充:

(最多只允许输入30个字)