Page 1 of 3 123 LastLast
Results 1 to 10 of 28

Thread: @AfterThrowing#Throwing argument name 'ex' was not bound in advice arguments

  1. #1

    Default @AfterThrowing#Throwing argument name 'ex' was not bound in advice arguments

    Hi there,

    Its almost 8hrs I got a stuck with the @AfterThrowing aspect problem,
    my enviornment is apsectj 1.5.3, asm 2.2, hibernate 3.2.0 and spring 2.0

    This is my configuration file

    <bean id="throwsAdvice" class="com.dpwn.newops.server.framework.intercepto r.exception.NewOpsAfterThrowsAdvise" />

    <!-- Enable aspects -->
    <aop:aspectj-autoproxy/>

    <aop:config>
    <aop:aspect id="afterThrowing" ref="throwsAdvice">
    <aopointcut id="executionOfMethods"
    expression="execution(* com..*.*(..))"/>
    <aop:after-throwing
    pointcut-ref="executionOfMethods"
    throwing="ex"
    method="afterThrowing"/>
    </aop:aspect>
    </aop:config>
    and aspect code is

    @Aspect
    public class NewOpsAfterThrowsAdvise {

    @AfterThrowing(pointcut="execution(* com.*.*(..))", throwing="ex")
    public void afterThrowing(Throwable ex) {
    ............
    }
    }

    The problem is that when i try to initialize the spring context, i get the following exception

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
    h name 'org.springframework.aop.aspectj.AspectJPointcutAd visor': Cannot create i
    nner bean '(inner bean)' while setting bean property 'advice'; nested exception
    is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean
    with name '(inner bean)': Invocation of init method failed; nested exception is
    java.lang.IllegalStateException: Throwing argument name 'ex' was not bound in ad
    vice arguments
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creati
    ng bean with name '(inner bean)': Invocation of init method failed; nested excep
    tion is java.lang.IllegalStateException: Throwing argument name 'ex' was not bou
    nd in advice arguments
    Caused by: java.lang.IllegalStateException: Throwing argument name 'ex' was not
    bound in advice arguments
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindExplicitArg
    uments(AbstractAspectJAdvice.java:412)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindArgumentsBy
    Name(AbstractAspectJAdvice.java:375)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.calculateArgume
    ntBindings(AbstractAspectJAdvice.java:331)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.afterProperties
    Set(AbstractAspectJAdvice.java:297)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.invokeInitMethods(AbstractAutowireCapableB eanFactory.java:1062)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.initializeBean(AbstractAutowireCapableBean Factory.java:1029)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFact ory.java:420)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver
    .resolveInnerBeanDefinition(BeanDefinitionValueRes olver.java:198)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver
    .resolveValueIfNecessary(BeanDefinitionValueResolv er.java:116)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:955)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:729)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBean
    Factory.createBean(AbstractAutowireCapableBeanFact ory.java:416)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getOb
    ject(AbstractBeanFactory.java:245)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistr
    y.getSingleton(DefaultSingletonBeanRegistry.java:1 41)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
    (AbstractBeanFactory.java:242)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
    (AbstractBeanFactory.java:156)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.
    preInstantiateSingletons(DefaultListableBeanFactor y.java:290)
    at org.springframework.context.support.AbstractApplic ationContext.refres
    h(AbstractApplicationContext.java:348)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:92)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<i
    nit>(ClassPathXmlApplicationContext.java:77)
    at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.init
    (ServerIntegrationApp.java:50)
    at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.main
    (ServerIntegrationApp.java:34)
    Exception in thread "main" java.lang.NullPointerException
    at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.init
    (ServerIntegrationApp.java:61)
    at com.dpwn.newops.integration.integrationtest.Server IntegrationApp.main
    (ServerIntegrationApp.java:34)

    I found similar queries in the forum and updated my Asm jar to 2.2 but still i get this exception.

    any thoughts what Im doing wrong?

    Thanks,
    Ravi

  2. #2

    Default

    Spring Gurus,
    any pointers for my problem?

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    You are trying to use both declarative (using aop aspectj and annotation based aspectj <aop:aspectj-autoproxy/>. Remove one of the 2 don't mix.

    I personally favor the declarative style, Annotations I still need to get used to .

    Remove annotations from your class
    Code:
    public class NewOpsAfterThrowsAdvise {
        public void afterThrowing(Throwable ex) { 
           //Do stuff
        }
    }
    Remove the <aop:aspectj-autoproxy/> from your config and I also think your aopointcut is in the wrong place, change your aop config

    Code:
    <aop:config>
        <aop:pointcut id="executionOfMethods" expression="execution(* com..*.*(..))"/>
        <aop:aspect id="afterThrowing" ref="throwsAdvice">
            <aop:after-throwing pointcut-ref="executionOfMethods" throwing="ex" method="afterThrowing"/>
        </aop:aspect>
    </aop:config>
    Last edited by Marten Deinum; Dec 12th, 2006 at 10:35 AM. Reason: Removed some typos
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4

    Default

    tried that, but hard luck!

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    what is happening now and can you post your new configuration also?
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6

    Default

    Hi,
    here's is my config file

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


    <bean id="throwsAdvice" class="com.dpwn.newops.server.framework.intercepto r.exception.NewOpsAfterThrowsAdvise" />

    <aop:config>
    <aopointcut id="afterThrowingID" expression="execution(* com..*.*(..))"/>
    <aop:aspect id="afterThrowing" ref="throwsAdvice">
    <aop:after-throwing pointcut-ref="afterThrowingID" throwing="ex" method="afterThrowing"/>
    </aop:aspect>
    </aop:config>

    </beans>


    and this is my Advise

    public class NewOpsAfterThrowsAdvise {
    public void afterThrowing(Throwable ex) {
    List <String>params = new ArrayList<String>();

    // Do something will all arguments
    System.out.print("Exception caught in the interceptor...");
    System.out.println(ex.getClass().getSimpleName());
    }
    }

    Exactly the same exception still repeats.

    Also i upgraded Asm from 2.2 to asm 2.2.2
    and using cglib-nodep 2.1_3

    Let me know if need other information?

  7. #7

    Default

    Also is there a way to find which version of the ASM is being used by spring at runtime? just to be sure spring is using ASM 2.2.2?

  8. #8
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    You still have the same exception or is it another one?

    Also is there a way to find which version of the ASM is being used by spring at runtime? just to be sure spring is using ASM 2.2.2?
    Hmm not that I know of, just make sure there are no other versions of the ASM jar in your classpath.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  9. #9

    Default

    it is the same exception!

    Im using maven2 to generate a assembled jar, Im explicitly removing the older version (that comes as a part of hibernate) and included the newer version of ASM.

  10. #10
    Join Date
    Sep 2004
    Location
    Philadelphia,PA
    Posts
    2

    Default

    Hi,
    I am also having the same issue. Were you able to solve the problem ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •