I have the following class as my point cut
public class GenricExceptionMapper implements ExceptionMapper<Exception> {
Logger logger = Logger.getLogger(GenricExceptionMapper.class);
public Response toResponse(Exception exception) {
logger.error(exception.getStackTrace());
logger.info("Exception Thrown");
String res="500 - Internal Server Error";
exception.printStackTrace();
logger.debug("Sending Http Response :"+res);
return Response.status(500).entity(res).build();
}
}
and the following advice defined for it...
@Aspect
public class ExceptionMapperAspect {
Logger logger = Logger.getLogger(ExceptionMapperAspect.class);
//@Context HttpServletRequest servletRequest;
@AfterReturning( pointcut="execution(* toResponse(..))")
public void logExceptionAspect()
{
//logger.info("statsKey in request object "+servletRequest.getAttribute("statsKey"));
}
when I try to run this I get the following exception error message..
**
Unable to find type arguments of interface javax.ws.rs.ext.ExceptionMapper
** The error is being thrown by this class http://grepcode.com/file/repo1.maven.org/maven2/org.jboss.resteasy/resteasy-jaxrs/2.2.2.GA/org/jboss/resteasy/util/Types.java#Types.getActualTypeArgumentsOfAnInterface%28java.lang.Class%2Cjava.lang.Class%29
part of RESTEasy code.
Is this because 'Spring AOP cannot advice pointcut class which implements a template interface'? Any ideas? How does Spring AOP create proxy objects for classes which implement parameterized interfaces?...does it use CGLIB or JDK Proxy?
I think your problem is somewhere else. I googled your exception
and found it in connection with JBoss RESTEasy. Try to comment out parts of your class or aspect code until you find the culprit.
BTW, your implementation of
toResponse
returns a raw type. Make thatResponse<Exception>
in order to be more type-safe and avoid the warnings.