title: Wildfly 10 and Jackson 2
body: <p>I have problem like 
  <a href="https://stackoverflow.com/questions/38355353/jackson-2-on-wildfly-10-how-to-load-providerbase">Jackson 2 on Wildfly 10: How to load ProviderBase?</a></p>
  
  <p>All dependecies in maven - provided</p>
  
  <p>jboss-deployment-structure
  Is it right?</p>
  
  <pre><code>&lt;deployment&gt;
      &lt;dependencies&gt;
          &lt;module name="by.lib" meta-inf="export" export="true"/&gt;
          &lt;module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="org.jboss.resteasy.resteasy-jaxrs"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-databind"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-core"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-annotations"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="org.jboss.resteasy.resteasy-jackson2-provider"  export="true"/&gt;--&gt;
      &lt;/dependencies&gt;
      &lt;exclude-subsystems&gt;
          &lt;subsystem name="logging"/&gt;
          &lt;subsystem name="resteasy"/&gt;
      &lt;/exclude-subsystems&gt;
  &lt;/deployment&gt;
  </code></pre>
  
  <p>In module  I have dependecies on jackson-jaxrs-base-2.8.5</p>
  
  <p>I catch different errors</p>
  
  <pre><code>13:10:27,005 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 59) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Failed to link com/fasterxml/jackson/jaxrs/base/ProviderBase (Module "by.lib:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\Work\Server_10.1.0\modules,D:\Work\Server_10.1.0\modules\system\layers\base))): javax/ws/rs/ext/MessageBodyReader
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      at org.jboss.threads.JBossThread.run(JBossThread.java:320)
  Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Failed to link com/fasterxml/jackson/jaxrs/base/ProviderBase (Module "by.lib:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\Work\Server_10.1.0\modules,D:\Work\Server_10.1.0\modules\system\layers\base))): javax/ws/rs/ext/MessageBodyReader
      at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
      at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>13:14:10,114 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 25) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Failed to link com/fasterxml/jackson/jaxrs/base/ProviderBase (Module "by.lib:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\Work\Server_10.1.0\modules,D:\Work\Server_10.1.0\modules\system\layers\base))): javax/ws/rs/ext/MessageBodyReader
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      at org.jboss.threads.JBossThread.run(JBossThread.java:320)
  Caused by: com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: Failed to link com/fasterxml/jackson/jaxrs/base/ProviderBase (Module "by.lib:main" from local module loader @1c2c22f3 (finder: local module finder @18e8568 (roots: D:\Work\Server_10.1.0\modules,D:\Work\Server_10.1.0\modules\system\layers\base))): javax/ws/rs/ext/MessageBodyReader
      at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2201)
      at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
      at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
      at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
  </code></pre>
  
  <p>When I try</p>
  
  <pre><code>@Provider
  @Produces(MediaType.APPLICATION_JSON)
  public class ConfiguredRESTProvider implements ContextResolver&lt;ObjectMapper&gt; {
  
      private static ObjectMapper mapper;
  
      static {
          mapper = new ObjectMapper();
          AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
          AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
          AnnotationIntrospector pair = AnnotationIntrospectorPair.create(primary, secondary);
          mapper.setAnnotationIntrospector(pair);
  
          mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
          // TODO Разбраться почему не отрабатывае? ("balanceAmount": 2.41E8)
          mapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true);
          mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
          mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
          // mapper.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS,true);
          mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
      }
  
      // public void ConfiguredRESTProvider() {
      // // ObjectMapper mapper = new ObjectMapper();
      // ObjectMapper mapper = locateMapper(type, json);
      // ObjectMapper mapper = super._mapperConfig.getDefaultMapper();
      // // AnnotationIntrospector primary = new JacksonAnnotationIntrospector();
      // // AnnotationIntrospector secondary = new JaxbAnnotationIntrospector(mapper.getTypeFactory());
      // // AnnotationIntrospector pair = AnnotationIntrospectorPair.create(primary, secondary);
      // // mapper.setAnnotationIntrospector(pair);
      //
      // mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
      // // TODO Разбраться почему не отрабатывае? ("balanceAmount": 2.41E8)
      // mapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true);
      // mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
      // mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
      // // mapper.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS,true);
      // mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
      // super.setMapper(mapper);
      // }
  
      @Override
      public ObjectMapper getContext(Class&lt;?&gt; aClass) {
          return mapper;
      }
  
  }
  </code></pre>
  
  <p>Jboss Structure</p>
  
  <pre><code>&lt;deployment&gt;
      &lt;dependencies&gt;
          &lt;module name="by.lib" meta-inf="export" export="true" services="import"/&gt;
          &lt;module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/&gt;
          &lt;!--&lt;module name="org.jboss.resteasy.resteasy-jackson2-provider" export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="org.jboss.resteasy.resteasy-jaxrs"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-databind"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-core"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="com.fasterxml.jackson.core.jackson-annotations"  export="true"/&gt;--&gt;
          &lt;!--&lt;module name="org.jboss.resteasy.resteasy-jackson2-provider"  export="true"/&gt;--&gt;
      &lt;/dependencies&gt;
      &lt;exclusions&gt;
          &lt;module name="org.jboss.resteasy.resteasy-jackson-provider"/&gt;
          &lt;module name="org.jboss.resteasy.resteasy-jettison-provider"/&gt;
          &lt;module name="org.jboss.resteasy.resteasy-jackson2-provider"/&gt;
      &lt;/exclusions&gt;
      &lt;exclude-subsystems&gt;
          &lt;subsystem name="logging"/&gt;
          &lt;!--&lt;subsystem name="resteasy"/&gt;--&gt;
      &lt;/exclude-subsystems&gt;
  &lt;/deployment&gt;
  </code></pre>
  
  <p>I have such error</p>
  
  <pre><code>2017-01-12 10:59:27,659 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 93) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./: java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
      at org.jboss.threads.JBossThread.run(JBossThread.java:320)
  Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector
      at java.lang.Class.getDeclaredConstructors0(Native Method)
      at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
      at java.lang.Class.getConstructors(Class.java:1651)
      at org.jboss.resteasy.util.PickConstructor.pickSingletonConstructor(PickConstructor.java:30)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.createConstructorInjector(ResteasyProviderFactory.java:2252)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2244)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.addContextResolver(ResteasyProviderFactory.java:1130)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1667)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1368)
      at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1290)
      at org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:571)
      at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:347)
      at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
      at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
      at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
      at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.
  </code></pre>