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.