I am working on an app that has some custom exceptions in a class hierarchy, rooted from RuntimeException. For use in CXF, they contain complementary ExceptionMapper classes. Basically, you are looking at a parallel hierarchy:
(abstract)BaseRuntimeException FooException BarException (abstract) BaseRuntimeExceptionMapper <T extends BaseRuntimeException> FooExceptionMapper<FooException> BarExceptionMapper <BarException> What is happening is that when FooException is thrown in the application, it is being handled by BarExceptionMapper. I did some digging around and saw that org.apache.cxf.jaxrs.provider.ProviderFactory.doCreateExceptionMapper() calls sort() on the list of exceptionmappers, using ExceptionMapperComparator, then returns the first mapper on the list. I don't quite have my head wrapped around the mechanism behind it, but what is happening is that the comparator is calling "InjectionUtils.getActualType(types1[0]);", which returns BaseRuntimeException for both classes, and thus, effectively, no sorting is done. Am I perhaps not using the ExceptionMapper mechanism in the way it was intended? Any help would be appreciated. Alex
