How to extract the ObjectMapper used by RestEasy's JacksonProvider to parse a .json file?

In my RestEasy (with Spring) app, I have extended RestEasyJacksonProvider (provided by RestEasy), to customize the configuration of the ObjectMapper a little bit like below

    public class JacksonProvider extends ResteasyJacksonProvider{

    public JacksonProvider(){
        ObjectMapper mapper = locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE);

        mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);

        mapper.getDeserializationConfig().addHandler(new DeserializationProblemHandler() {
            public boolean handleUnknownProperty(DeserializationContext ctxt, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException, JsonProcessingException {
                logger.warn(String.format("Could not deserialize property with name '%s' on object of type '%s'", propertyName, beanOrClass.getClass().getName()));
                return true;


The app has a service which with methods for reading json data as well as importing .json files.

While reading json data, I specify the applicaion/json in @Consumes and JacksonProvider takes care of parsing it to object. I want to use the same JacksonProvider while reading the .json file so that my custom mapper properties are applied while import also. Something like this:

Object dto = jacksonProvider.readFrom(Object.class, Object.class, null, MediaType.APPLICATION_JSON_TYPE , null , new FileInputStream("input.json"));

However, when I do this, I get an exception, stacktrace below


    at com.test.JSONImportTest.unmarshal(

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

    at java.lang.reflect.Method.invoke(Unknown Source)

    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(


    at org.junit.runners.model.FrameworkMethod.invokeExplosively(

    at org.junit.internal.runners.statements.InvokeMethod.evaluate(

    at org.junit.runners.ParentRunner.runLeaf(

    at org.junit.runners.BlockJUnit4ClassRunner.runChild(

    at org.junit.runners.BlockJUnit4ClassRunner.runChild(

    at org.junit.runners.ParentRunner$

    at org.junit.runners.ParentRunner$1.schedule(

    at org.junit.runners.ParentRunner.runChildren(

    at org.junit.runners.ParentRunner.access$000(

    at org.junit.runners.ParentRunner$2.evaluate(




    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(


    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException:




    ... 24 more

Caused by: java.lang.ClassNotFoundException:

    at$ Source)

    at$ Source)

    at Method)

    at Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Unknown Source)




    ... 26 more

Is there a way to use the JacksonProvider to parse json outside of the resteasy context?


Ok I answer myself. There are basically two options:

1/ Get the ObjectMapper from the custom provider using

ObjectMapper mapper = jacksonProvider.locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE)

and then use this mapper to read json

mapper.readValue(new File("src/test/resources/input.json"), Object.class);

2/ Create a custom ObjectMapper (like mentioned here) and use that mapper to read json from both JacksonProvider as well as while reading the .json file.

I went with the first option.

Need Your Help

TLB invlpg instruction has long latency

x86 virtual-memory tlb

So I'm working on this kernel module that does some page table manipulation and I noticed that flushing a TLB entry is slow. How slow you ask? Over 100 ns per call to invlpg! That's 280 cycles or m...

pyobjc installation failure: xcode-select: error: tool 'xcodebuild' requires Xcode

python xcode python-2.7 pip pyobjc

I need pyobcj in order to have pyttsx work. When I attempt to install pyobjc with pip, I get the following: