How to register a custom exception mapping engine in Mule + Jersey + Spring?

I built an exception mapping block using the JAX-RS ExceptionMapper:

@Provider
public class MyCustomExceptionMapper implements ExceptionMapper<MyException>{...}

I don’t understand how to register it so that when calling MyException, the translator is called automatically. The environment I use is Mule + Jersey + Spring.

+3
source share
3 answers

If you are using 3.1.2-SNAPSHOT + or 3.2-SNAPSHOT +, you can do this:

<jersey:resources>
    <component class="org.mule.module.jersey.HelloWorldResource"/>
    <jersey:exception-mapper class="org.mule.module.jersey.exception.HelloWorldExceptionMapper" />
</jersey:resources>
+4
source
+2
source

Mule 3.4.0 :

https://www.mulesoft.org/jira/browse/MULE-5458

<sub-flow name="RestServiceFlow">
    <jersey:resources>
        <component class="org.example.AResource"/>
        <component class="org.example.BResource"/>
        <jersey:exception-mapper class="org.example.AExceptionHandler" />
        <jersey:exception-mapper class="org.example.BExceptionHandler" />
    </jersey:resources>
</sub-flow>

@Provider, .

+2
source

All Articles