当前位置: 首页 > 知识库问答 >
问题:

使用Spring 3.1.2实现@AspectJ时面临的问题

穆阳炎
2023-03-14

我试图在Spring3.1.5上用AOP实现日志记录。但在运行时,我会得到以下异常

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.manh.fm.bid.ejb.BidMgr' defined in class path resource [appCtx-fm.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [null] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
    ... 89 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.manh.fm.bid.ejb.BidMgr' defined in class path resource [appCtx-fm.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [null] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:609)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:105)
    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:147)
    ... 91 more
Caused by: org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [null] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
    at org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry.getInterceptors(DefaultAdvisorAdapterRegistry.java:88)
    at org.springframework.aop.framework.DefaultAdvisorChainFactory.getInterceptorsAndDynamicInterceptionAdvice(DefaultAdvisorChainFactory.java:61)
    at org.springframework.aop.framework.AdvisedSupport.getInterceptorsAndDynamicInterceptionAdvice(AdvisedSupport.java:482)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:188)
    at $Proxy136.getTransactionAttribute(Unknown Source)
    at org.springframework.transaction.interceptor.TransactionAttributeSourcePointcut.matches(TransactionAttributeSourcePointcut.java:36)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:227)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:264)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:296)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 106 more

下面是我的aspect类的详细信息:

@Aspect
public class LoggingAspect {


    @Before("allGetters()")
    public void LoggingAdvice(){

        System.out.println("AspectJ Logging");
    }
    @Pointcut("execution(* com.manh.fm.kjb.MgrBean.processMyAction(..))")
    public void allGetters(){}

}
 <?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:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
             http://www.springframework.org/schema/tx
              http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
              http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<aop:aspectj-autoproxy/>
<bean
        id="com.manh.fm.bid.ejb.BidMgr"
        autowire="default"
        class="com.manh.fm.bid.ejb.BidMgrBean"
        dependency-check="default"
        lazy-init="default"
         >
    </bean>
<bean id="loggingAspect" 
           class="com.manh.fm.aspectj.logger.LoggingAspect"/>
</beans>

伙计们,我真的被这个困住了,我也是Aop的新手,请帮我解决这个问题!!!

共有1个答案

东方弘壮
2023-03-14

尝试实现“org.aopalliance.intercept.MethodInterceptor”,它是“org.aopalliance.aop.advice”的“子接口”,正如错误所暗示的那样。

 类似资料:
  • 在访问网址时,我得到以下异常。 org.springframework.web.util.NestedServletExc0019:请求处理失败;嵌套异常是java.lang.不支持操作异常:不能更改HTTP接受标头-使用不同的区域设置解析策略org.springframework.web.servlet.FrameworkServlet.process请求(FrameworkServlet.ja

  • 问题内容: 我正在寻找一个使用AspectJ进行虫洞模式实现的示例(如果Guice AOP能够实现此功能,我将很感兴趣)。 蠕虫漏洞实际上使您可以沿调用流传递其他参数,例如: 我相信Ramnivas Laddad在他的《 AspectJ in Action》一书中有这样的例子。 提前致谢。 问题答案: 实际上,AspectJ in Action中 有一个示例。如果查看目录,您会发现您正在寻找第12

  • 我正在尝试安装android studio。在完成安装过程后,当我打开它时。它没有打开。搜索很多关于它的信息,但要找出问题所在。 我面临问题的窗口截图 当我单击finish按钮时,应用程序没有打开。JDK已正确安装在我的笔记本电脑中。我的笔记本电脑的进程是奔腾四核

  • 我在使用selenium web驱动程序在两个窗口之间切换时遇到了问题。 我正在使用selenium WebDriver实现网页的自动化。 在父窗口中,我需要单击一个按钮,它将打开一个新窗口。我需要在新窗口上填充一些数据,然后单击保存按钮。单击保存按钮后,该窗口将自动关闭,并重定向到父窗口,父窗口将被刷新以显示在新窗口上添加的数据。但在重定向期间,它无法切换回父窗口,并抛出安全违规错误。 我正在使

  • 该应用程序没有针对/error的显式映射,因此您将其视为一种后退。 美国东部时间2017年12月11日上午10:19:54出现意外错误(类型=不可接受,状态=406)。找不到可接受的表示