7 Replies Latest reply on Feb 7, 2011 3:49 PM by andrewwot

    Wrong type of advice when using @Bind annotation

    ivv-private

      Hi, All.

       

      I'm using JBoss AS 5.1.0.GA.

      I set "BEFORE" advice, but system searching for "AROUND".

      wtf?

       

       

      {code}

      package ru.lanit.samara.liferay;

      import org.jboss.aop.AdviceType;
      import org.jboss.aop.Aspect;
      import org.jboss.aop.Bind;

      @Aspect
      public class NativeSQLCorrecter
      {
          @Bind(type=AdviceType.BEFORE, pointcut="execution(* $instanceof{com.liferay.portal.kernel.dao.orm.Session}->createSQLQuery(..))")
          public void before() {
              System.out.println("trying");
          }
      }
      {code}

       

      JBoss AS log:

       

      {quote}

      com.liferay.portal.kernel.exception.SystemException: org.jboss.aop.advice.NoMatchingAdviceException: No matching around advice called 'before' could be found in ru.lanit.samara.liferay.NativeSQLCorrecter for joinpoint Method[method=public com.liferay.portal.kernel.dao.orm.SQLQuery com.liferay.portal.dao.orm.hibernate.SessionImpl.createSQLQuery(java.lang.String) throws com.liferay.portal.kernel.dao.orm.ORMException]
        On method 'public void ru.lanit.samara.liferay.NativeSQLCorrecter.before()'
          return value cannot be void (it must match the joinpoint return type)
          at com.liferay.portlet.announcements.service.persistence.AnnouncementsEntryFinderImpl.findByDisplayDate(AnnouncementsEntryFinderImpl.java:218)
          at com.liferay.portlet.announcements.service.impl.AnnouncementsEntryLocalServiceImpl.checkEntries(AnnouncementsEntryLocalServiceImpl.java:130)
          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) ...

      {quote}

        • 1. Re: Wrong type of advice when using @Bind annotation
          flavia.rainone

          This error you are seeing is totally unexpected, as this feature is part of our testsuite.

           

          What is the version of JBoss AOP you are using? (you can check on the manifest of jboss-aop.jar in the server)

           

          Have you tried this scenario on JBoss AOP standalone?

          • 2. Re: Wrong type of advice when using @Bind annotation
            andrewwot

            We are experiencing the same issue with before/after lightweight advices inside container (JBoss AS 5.1.0) with both xml and annotation configurations

             

            AOP version  2.1.6.GA_CP01

             

            Xml Configuration

            <?xml version="1.0" encoding="UTF-8"?>

            <aop xmlns="urn:jboss:aop-beans:1.0">

                <aspect class="DocTypeResourceAspect"

                    scope="PER_VM" />

                <bind

                    pointcut="execution(* DocTypeResourceImpl->*(..))">

                    <before name="beforeAdvice" aspect="DocTypeResourceAspect" />

               </bind>

            </aop>

             

            Aspect class

             

            public class DocTypeResourceAspect  {

             

                public void beforeAdvice(@JoinPoint JoinPointBean joinPointBean)

                {

             

                    super.beforeAdvice(joinPointBean);

                    getLogger().info("beforeInvoke:" + joinPointBean);

                }

             

            }

             

            Exception we are getting:

             

            org.jboss.aop.advice.NoMatchingAdviceException: No matching around advice called 'beforeAdvice' could be found in DocTypeResourceAspect for joinpoint Method[method=public javax.ws.rs.core.Response DocTypeResourceImpl.getDocTypes()]

              On method 'public void DocTypeResourceAspect.beforeAdvice(org.jboss.aop.joinpoint.JoinPointBean)'

                @JoinPoint-annotated parameter is not assignable from expected type class org.jboss.aop.joinpoint.MethodInvocation

                at org.jboss.aop.advice.annotation.AdviceMethodFactory.findAdviceMethod(AdviceMethodFactory.java:295)

                at org.jboss.aop.instrument.JoinPointGenerator$AdviceSetups.<init>(JoinPointGenerator.java:1612)

                at org.jboss.aop.instrument.JoinPointGenerator.initialiseAdviceInfosAndAddFields(JoinPointGenerator.java:537)

                at org.jboss.aop.instrument.JoinPointGenerator.generateJoinpointClass(JoinPointGenerator.java:367)

                at org.jboss.aop.instrument.JoinPointGenerator.doGenerateJoinPointClass(JoinPointGenerator.java:285)

                at org.jboss.aop.instrument.JoinPointGenerator.access$300(JoinPointGenerator.java:77)

                at org.jboss.aop.instrument.JoinPointGenerator$GenerateJoinPointClassAction$2.generateJoinPointClass(JoinPointGenerator.java:1730)

                at org.jboss.aop.instrument.JoinPointGenerator.generateJoinPointClass(JoinPointGenerator.java:250)

                at org.jboss.aop.GeneratedClassAdvisor.generateJoinPointClass(GeneratedClassAdvisor.java:1047)

                at DocTypeResourceImpl$DocTypeResourceImplAdvisor.getDocTypes_N_5161450178620338716(DocTypeResourceImpl$DocTypeResourceImplAdvisor.java)

             

             

            Classical around advices and interceptors work just fine, we even tried to modify aop.xml to explicitly use

             

            <property name="instrumentor">org.jboss.aop.instrument.GeneratedAdvisorInstrumentor</property>

             

            even that it's supposed to be default instrumentor, but it didn't help.

             

            What version of container actually supports lightweight advices?

             

            Thanks

            • 3. Re: Wrong type of advice when using @Bind annotation
              flavia.rainone

              AFAIK, your example should work. I'll investigate to see what is going on.

              • 4. Re: Wrong type of advice when using @Bind annotation
                andrewwot

                Hi Flavia, any update on that, we are using load time weaving if that's matter?

                 

                Thanks

                • 5. Re: Wrong type of advice when using @Bind annotation
                  flavia.rainone

                  Sorry, Andrew, but not yet. I'll check this later this week.

                  • 6. Re: Wrong type of advice when using @Bind annotation
                    flavia.rainone

                    Have you checked the version of jboss-aop.jar in the container? If yes, I would try installing the latest JBoss AOP version available for download. There is a jboss-50-install script at the distribution zip file that could be used for that. If the error persists, let me know.

                    • 7. Re: Wrong type of advice when using @Bind annotation
                      andrewwot

                      Hi Flavia, the AOP version was specified in my mesage, it's 2.1.6.GA_CP01. We could not use the latest version of JBoss AOP with JBoss EAP 5.0 or 5.1 due to some libraries incompatibilites. Plus replacing component versions in EAP release is not officially supported.

                      Can you please tell us which version worked for you and if possible started from which version lightweight aspects have become functional inside the container.

                       

                      Thanks again for your help,

                      Andrew