Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1107645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:58:02+00:00 2026-05-17T01:58:02+00:00

The following is my pointcut and advise declaration //PointCut on A method which takes

  • 0

The following is my pointcut and advise declaration

//PointCut on A method which takes two parameters and is in a DAO
@Pointcut("execution(backend.repository.QuestionsRepository.AnswerQuestion (..))")
public void answerQuestionPointCut() {}


@Around(
   value="web.activity.advisors.UserActivityAdvisor.answerQuestionPointCut()",
   argNames="question,answer"
)

 // Do something

}

I get the following error

Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'name pattern' at character position 65
execution(backend.repository.QuestionsRepository.AnswerQuestion (..))
                                                                 ^

Am stuck on this, Any pointers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:58:02+00:00Added an answer on May 17, 2026 at 1:58 am

    You are missing the return type:

    @Pointcut("execution(* backend.repository.QuestionsRepository.AnswerQuestion (..))")
    

    and you have to bind the argument names, something like this:

    @Pointcut("execution(* backend.repository.QuestionsRepository.AnswerQuestion (..)) 
    && args(question, answer)") // wrapped for readability only
    

    Example Solution

    Service Interface:

    package foo.bar.service;
    public interface Service{
        void whack(String thing, Integer thang);
    }
    

    Implementation class:

    package foo.bar.service;
    public class DefaultService implements Service{
        @Override
        public void whack(final String thing, final Integer thang){
            System.out.println(
                "Inside thing: " + thing + ", inside thang: " + thang
            );
        }
    }
    

    Spring AOP aspect:

    @Aspect
    public class ServiceAspect{
    
        @Pointcut("execution(* foo.bar.service.*.*(..))")
        public void serviceMethodExecution(){
        }
    
        @Around(value = "serviceMethodExecution() && args(param1, param2)")
        public void aroundServiceMethodExecution(final ProceedingJoinPoint pjp,
            final String param1,
            final Integer param2) throws Throwable{
    
            System.out.println("Before thing: " + param1 + ", before thang: "
                + param2);
            pjp.proceed();
            System.out.println("After thing: " + param1 + ", after thang: "
                + param2);
        }
    
    }
    

    Spring Context XML:

    <aop:aspectj-autoproxy proxy-target-class="false"  />
    <bean class="foo.bar.service.DefaultService" />
    <bean class="foo.bar.aspects.ServiceAspect" />
    

    Main class for testing:

    Now here’s a main method to test the whole process. It starts a Spring ApplicationContext without XML configuration with the above XML defining the service bean and the aspect (it turns out that the solution without XML only worked because I had AspectJ weaving turned on, I don’t know what beans I have to include to enable aspectj-autoproxy, so I now use ClassPathXmlApplicationContext with this minimal XML):

    public static void main(final String[] args){
        final ApplicationContext applicationContext =
            new ClassPathXmlApplicationContext("classpath:/aspectContext.xml");
        final Service service = applicationContext.getBean(Service.class);
        service.whack("abc", 123);
    }
    

    Output:

    Before thing: abc, before thang: 123
    Inside thing: abc, inside thang: 123
    After thing: abc, after thang: 123
    

    This should get you started. Basically: you need to check that the methods you are intercepting are backed by a service interface if you use JDK proxies (spring default). Read here about Spring AOP proxy mechanisms.

    Note:

    As you see I bind the method arguments to the aspect, not the pointcut, hence making the pointcut reusable for methods with different argument signatures. But it would also be possible to bind them in the pointcut, like this:

    @Pointcut(value = "execution(* foo.bar.service.*.*(..)) && args(a,b)",
              argNames = "a,b")
    public void serviceMethodExecution(final String a, final Integer b){
    }
    
    @Around(value = "serviceMethodExecution(param1, param2)",
            argNames = "param1,param2")
    public void aroundServiceMethodExecution(final String param1,
        final Integer param2,
        final ProceedingJoinPoint pjp) throws Throwable{
    
        System.out.println("Before thing: " + param1 + ", before thang: "
            + param2);
        pjp.proceed();
        System.out.println("After thing: " + param1 + ", after thang: "
            + param2);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come up with the following pointcut that I use for tracing method
I am a newbie to aspectj... I have written the following aspect which is
i am trying to use aop pointcut stuff for transaction but gettig error i
Ok, last question for today I promise! I have the following line of code
Following on from my recent question on Large, Complex Objects as a Web Service
Following my question regarding a .NET YAML Library ... as there doesn't seem to
Following this question: Good crash reporting library in c# Is there any library like
Following Izb's question about Best binary XML format for JavaME , I'm looking for
Following on from this question what would be the best way to write a
I have a service class implemented in Java 6 / Spring 3 that needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.