随笔-112  评论-73  文章-0  trackbacks-0
写了一个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)


posted on 2008-04-07 23:04 Libo 阅读(1073) 评论(1)  编辑  收藏

评论:
# re: spring 2.0 aop 在glassfish下面报错 2008-04-08 13:35 | Libo
问题解决:
将切入点和装备这样写就可以了.
@Pointcut("execution(public * cn.xiangyunsoft.publicinfo.service.IInventoryService.matchingOne(..))")
public void service() {
}

@Around("service() && args(str)")
public Object aroundAspect(ProceedingJoinPoint pjp, String str) {

真不知道为什么...
现在已经升级为spring2.5.3了在2.0下不知道怎么样.
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: