写了一个aop的例子.用测试跑和在TOMCAT下跑都没有问题.唯独到glassfihs下面运行就出错.
Caused by: org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer$AmbiguousBindingException: Still 3 unbound args at this(),target(),args() binding stage, with no way to determine between them
这个错误没怎么看明白,谁能给解释一下.
下面是代码.
@Aspect
public class InventoryMatchingAspect {
private Cache cache;
public void setCache(Cache cache) {
this.cache = cache;
}
@Pointcut("execution(public * cn.xiangyunsoft.publicinfo.service.IInventoryService.matchingOne(..)) && args(str)")
public void service(String str) {
}
@Around("service(str) && target(obj) && this(proxy)")
public Object aroundAspect(ProceedingJoinPoint pjp, String str, Object obj,
Object proxy) {
try {
String key = getCacheKey(str);
Element element = cache.get(key);
if (element == null) {
Logger.debug(key + ",not in cache, load from database.");
Object o = pjp.proceed();
if (o != null) {
element = new Element(key, o);
cache.put(element);
}
}
return element.getValue();
} catch (Throwable e) {
Logger.error(getClass(), "查询存货是出错");
e.printStackTrace();
}
return null;
}
private String getCacheKey(String inventoryId) {
return Inventory.class.getName() + "_" + inventoryId;
}
<aop:aspectj-autoproxy />
<bean id="inventoryMatchingAspect"
class="cn.xiangyunsoft.publicinfo.aspect.InventoryMatchingAspect">
<property name="cache" ref="ehCache" />
</bean>
下面是详细的错误:
Caused by:
org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer$AmbiguousBindingException:
Still 3 unbound args at this(),target(),args() binding stage, with no
way to determine between them
at org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer.maybeBindThisOrTargetOrArgsFromPointcutExpression(AspectJAdviceParameterNameDiscoverer.java:535)
at org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer.getParameterNames(AspectJAdviceParameterNameDiscoverer.java:279)
at org.springframework.core.PrioritizedParameterNameDiscoverer.getParameterNames(PrioritizedParameterNameDiscoverer.java:54)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.bindArgumentsByName(AbstractAspectJAdvice.java:373)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.calculateArgumentBindings(AbstractAspectJAdvice.java:344)
at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvice(ReflectiveAspectJAdvisorFactory.java:219)
at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.instantiateAdvice(InstantiationModelAwarePointcutAdvisorImpl.java:145)
at org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl.<init>(InstantiationModelAwarePointcutAdvisorImpl.java:94)
at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisor(ReflectiveAspectJAdvisorFactory.java:135)
at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory$1.doWith(ReflectiveAspectJAdvisorFactory.java:75)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:193)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:170)
at org.springframework.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactory.getAdvisors(ReflectiveAspectJAdvisorFactory.java:71)
at org.springframework.aop.aspectj.annotation.BeanFactoryAspectJAdvisorsBuilder.buildAspectJAdvisors(BeanFactoryAspectJAdvisorsBuilder.java:111)
at org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator.findCandidateAdvisors(AnnotationAwareAspectJAutoProxyCreator.java:85)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:83)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1181)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:247)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:796)
at org.springframework.context.support.AbstractApplicationContext.registerListeners(AbstractApplicationContext.java:592)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:349)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4523)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5184)
at com.sun.enterprise.web.WebModule.start(WebModule.java:326)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:973)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:957)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:688)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1584)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1222)
at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:182)
at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:278)
at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:974)
at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:961)
at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464)
at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176)
at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308)
at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:226)
at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298)
at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:591)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.start(PEDeploymentService.java:635)
at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.start(ApplicationsConfigMBean.java:744)
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:585)
at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:375)
at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:358)
at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:464)
at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213)
at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90)
at $Proxy1.invoke(Unknown Source)
at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304)
at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:174)
at com.sun.enterprise.deployment.client.DeploymentClientUtils.startApplication(DeploymentClientUtils.java:145)
at com.sun.enterprise.deployment.client.DeployAction.run(DeployAction.java:537)
at java.lang.Thread.run(Thread.java:595)
分享到:
相关推荐
spring-aop-2.0.jar spring-aop-2.5.1.jar spring-aop-2.5.2.jar spring-aop-2.5.4.jar spring-aop-2.5.5.jar spring-aop-2.5.6.jar spring-aop-3.0.0.RELEASE.jar spring-aop-3.0.2.RELEASE.jar spring-aop-sources...
网上找了很多例子多数都不能运行。包括after,before,round,throw切入,可对类直接拦截,不需要定义接口文件,自己研究了2天整理出来的。 Spring AOP 的完整例子,可直接运行。带jar包。
Spring 2.0 是一个非常重要的Java框架,它在企业级应用开发中占据了核心地位,尤其是在基于Java的轻量级应用程序上下文(IoC)和面向切面编程(AOP)方面。本手册和使用指南提供了全面的Spring 2.0相关知识,包括其...
Spring 2.0在1.x的基础上进行了大量改进,引入了更多特性,如支持JSR-250规范,增强了AOP,以及对Web服务的支持。 二、依赖注入 依赖注入是Spring的核心特性,允许开发者在运行时将对象及其依赖关系动态组合在一起...
1. **AOP(面向切面编程)增强**:Spring 2.0加强了对AOP的支持,允许开发者定义更复杂的切面,如注解驱动的切面,提供了更多的通知类型,如around、before、after等,使得代码更加模块化和可维护。 2. **注解驱动...
Spring 2.0是Spring框架的一个重要版本,它在Java企业级应用开发中扮演着核心角色。本教程将深入探讨Spring 2.0的核心特性和关键功能,旨在帮助开发者掌握这个强大框架的基础与高级概念。 1. **依赖注入...
虽然不在Spring 2.0核心包内,但Spring Web Flow是一个可选组件,用于构建复杂的Web导航流程,它与Spring MVC完美结合,提供了流程控制的强大工具。 总结,Spring 2.0是一个功能强大且成熟的框架,其依赖注入、AOP...
Spring 2.0是Java开发中的一个里程碑,它在企业级应用开发中扮演着至关重要的角色,特别是对于依赖注入(IoC)和面向切面编程(AOP)的支持。本学习提纲旨在为初学者提供一份详尽的Spring 2.0学习指南,帮助他们系统...
在Spring 2.0版本中,引入了许多重要的改进和新特性,使得开发者能够更加高效地进行开发工作。以下是对Spring 2.0的一些关键知识点的详细解释: 1. **依赖注入 (Dependency Injection, DI)**:Spring 2.0继续强化了...
1. **AOP(面向切面编程)增强**:Spring 2.0 提供了更强大的面向切面编程支持,允许开发者定义更复杂的切面,包括基于注解的切点表达式和更多的通知类型。这使得代码更加整洁,业务逻辑与系统服务(如事务管理)...
Spring 2.0 是Spring框架的一个重要版本,它在Java企业级应用开发中扮演着核心角色。这个版本引入了许多新特性,增强了框架的功能和灵活性。本文将深入探讨Spring 2.0源代码中的关键知识点,帮助开发者理解其内部...
在这个压缩包中,包含了该手册涉及的全部十章节的源码,这为我们深入研究Spring 2.0的核心特性、配置以及编程模式提供了宝贵材料。 首先,Spring 2.0是一个重要的版本升级,引入了许多新特性和改进,旨在提高开发...
Spring 2.0版本是Spring发展历史上的一个重要里程碑,它在前一个版本的基础上进行了大量的优化和改进,引入了许多新的特性和功能。 #### 二、Spring 2.0的核心技术 ##### 1. 依赖注入(Dependency Injection, DI)...
在Spring 2.0中,最重要的更新之一是AOP(面向切面编程)的增强。这一版本引入了基于注解的AOP支持,使得开发者可以更直观地定义切面,无需编写XML配置。例如,@Before、@After、@Around等注解可以直接应用于方法上...
在Spring 2.0版本中,引入了许多新特性,如AOP(面向切面编程)的增强、更强大的数据访问支持、Web服务支持等,这些都在书中得到了详尽的讲解。 1. **依赖注入**:Spring的核心特性之一,它允许开发者通过配置来...
Spring 2.0在AOP方面进行了增强,支持更多的通知类型,包括环绕通知,使切面的实现更为灵活。 Spring MVC是用于构建Web应用程序的模块,它提供了模型-视图-控制器架构,将业务逻辑、数据处理和用户界面分离。在...
这本书通过对Spring 2.0版本的源代码进行深入剖析,旨在帮助读者全面理解Spring的工作机制,提升在实际开发中的应用能力。源代码的分享提供了实践和学习的宝贵资料。 Spring是一个开源的Java应用程序框架,它简化了...
其次,AOP在Spring 2.0中也有了显著提升。AOP允许开发者将关注点(如日志、事务管理)与业务逻辑分离,提高了代码的模块化。2.0版本增加了更多的通知类型(advisors)和切点表达式(pointcuts),增强了AOP的表达...