Apache CXF REST Services w/ Spring AOP
- by jconlin
I'm trying to get Apache CXF JAX-RS services working with Spring AOP. I've created a simple logging class:
public class AOPLogger{
public void logBefore(){
System.out.println("Logging Before!");
}
}
My Spring configuration (beans.xml):
<aop:config>
<aop:aspect id="aopLogger" ref="test.aop.AOPLogger">
<aop:before method="logBefore" pointcut="execution(* test.rest.RestService(..))"/>
</aop:aspect>
</aop:config>
<bean id="aopLogger" class="test.aop.AOPLogger"/>
I always get an NPE in RestService when a call is made to a Method getServletRequest(), which has:
return messageContext.getHttpServletRequest();
If I remove the aop configuration or comment it out from my beans.xml, everything works fine.
All of my actual Rest services extend test.rest.RestService (which is a class) and call getServletRequest(). I'm just trying to just get AOP up and running based off of the example in the CXF JAX-RS documentation. Does anyone have any idea what I'm doing wrong?
Thanks!