0

I have the following spring REST controller:

@RestController
public class QuoteController {

    @RequestMapping(value = {"/quotes"}, method = RequestMethod.GET)
    public String getQuotes(@PathVariable("accountId") String accountId)
            throws Exception {

        return "100.00";
    }

}

and the following aspect and context config files:

@Component
@Aspect
public class TestControllerAspect {

    @Around("execution(@org.springframework.web.bind.annotation.RequestMapping public * com.test.controller..*.*(..))")
    public Object controllerAroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        Object[] args = joinPoint.getArgs();
        for (Object o : joinPoint.getArgs()) {
            System.out.println(o.toString());
        }
        return joinPoint.proceed();
    }
}

@Configuration
@ComponentScan("com.test.controller")
@EnableWebMvc
@EnableCaching
@EnableAspectJAutoProxy
public class WebConfig extends WebMvcConfigurerAdapter {

    @Bean
    public TestControllerAspect controllerAspect() {
        return new TestControllerAspect();
    }
}

When I deploy this code in JBoss EAP 6, I get the following error from spring framework:

Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error annotation type patterns are only supported at Java 5 compliance level or above.

I have tried the above pointcut using @annotation but received similar error. There were similar posts in stackoverflow about these errors but they were referring to an older version of spring and aspectj weaver jars. I am using spring 4.1.6 which I believe already repackages aspectj classes with spring.

Did anyone else encounter this error. By the way, I am using java 1.8. Appreciate the response.

mikeb
  • 11
  • 3
  • It sounds like you need to upgrade Aspect-J, see [this question](http://stackoverflow.com/questions/15678417/error-when-using-aspectj-aop-with-java-7). – beerbajay May 06 '15 at 06:08
  • That question was talking about spring 3.1 with aspect-j 1.5.4. The recommendation was to upgrade to 1.7.x. In my case I have spring 4.1.6 with aspect-j 1.8.5 as part of spring not a separate jar anymore. Thanks – mikeb May 06 '15 at 17:54

0 Answers0