'Error creating bean with name 'org.springframework.transaction.annotation. error at ::0 formal unbound in pointcut Spring AOP

I'm facing an error that mentioned below, related to Spring Aspect Oriented Programming.

2022-05-06 17:26:44 ERROR org.springframework.boot.SpringApplication.java Line 826: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'projectingArgumentResolverBeanPostProcessor' defined in class path resource [org/springframework/data/web/config/ProjectingArgumentResolverRegistrar.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut 

Previously I used applicationContext.xml file. But after I added @Configuration annotation to the CommonController class and removed applicationContext.xml file. I just search some solutions and apply to my code, but still didn't clear my issue. Hope your support and attach my code below, thank you.

Aspect.java

package com.intervest.medical.aggregator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Aspect {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    public void aspect() {
        logger.info("FFFFFFFFFFFFF {} | request {} | registerParam {}", "RETURNVALUE", "request", "registerParam");
    }
}

CommonController.java

    package com.intervest.medical.aggregator.controller;
    
    import com.healix.blackboxdirect.ArrayOfString;
    import com.healix.blackboxdirect.DirectServiceSoap;
    import com.intervest.medical.engine.domain.*;
    import com.intervest.medical.engine.service.*;
    import com.intervest.medical.engine.util.*;
    import com.intervest.medical.engine.constants.RegisterError;
    import com.intervest.medical.engine.constants.RegisterState;
    import com.intervest.medical.engine.dto.ValidationDTO;
    import com.intervest.medical.engine.dto.XmlResultDTO;
    import com.intervest.medical.engine.enums.Stub;
    import org.apache.commons.lang.StringUtils;
    import org.aspectj.lang.annotation.After;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Before;
    import org.aspectj.lang.annotation.Pointcut;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.*;
    
    import javax.servlet.http.HttpServletRequest;
    import java.util.*;
    
    @Controller
    @Aspect
    @Configuration
    public class CommonController {
    
        private static final Logger LOG = LoggerFactory.getLogger(CommonController.class);
    
        @Autowired
        ScreeningProxyService screeningProxyService;
    
        @Autowired
        MedicalDataKeeperService medicalDataKeeperService;
    
        @Autowired
        private MedicalUrlService medicalUrlService;
    
        @Autowired
        private MedicalConstantsService medicalConstantsService;
    
        @Autowired
        private MedicalConfigService medicalConfigService;
    
        @ResponseBody
        @Pointcut("within(com.intervest.medical.aggregator.Aspect.*)")
        @Before("reScreenAndGetXmls(@RequestBody RegisterParam registerParam)")
        @RequestMapping(value = "/medical/screeningData/register", method = RequestMethod.POST)
        public RegisterResult doScreen(HttpServletRequest request, @RequestBody RegisterParam registerParam) {
    
            ValidationDTO intiValidationDTO = screeningProxyService.initialValidation(registerParam, false);
            if (!intiValidationDTO.isSuccess()) {
                return new RegisterResult(null, intiValidationDTO.getErrMsg());
            }
    
             ........................
}

Application.java

  public static void main(String[] args) throws Exception {
        SpringApplication springApplication = new SpringApplication(Application.class);
        springApplication.setBannerMode(Banner.Mode.OFF);
        Environment environment = springApplication.run(args).getEnvironment();
        ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
        Aspect e = (Aspect) applicationContext.getBean("Aspect");
        e.aspect();

}


Solution 1:[1]

I solved my issue. There was an issue with my Aspect class. I didn't add relevant annotations to that class. I was able to solve the issue after adding those annotations to the Aspect class and removing unwanted annotations from controller class.

 package com.intervest.medical.aggregator;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    @org.aspectj.lang.annotation.Aspect
    @Component
    public class Aspect {
        private Logger logger = LoggerFactory.getLogger(this.getClass());
    
        public void aspect() {
            logger.info("FFFFFFFFFFFFF {} | request {} | registerParam {}", "RETURNVALUE", "request", "registerParam");
      

  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1