2 Replies Latest reply on Sep 30, 2014 8:53 AM by tari_manga

    Jackson ObjectMapper dependecy problem

    Sascha Retter Newbie

      Hello,

       

      I am new to JBoss and at the moment I try to gain my first experiences. My first project is a simple restservice. Some of my objects are containing timestamps and I want to serialize my json objects using a specfic format.

       

      So I tried to configure my ObjectMapper according to:

       

      https://community.jboss.org/message/783055#783055

       

      But now I am having a problem - I suppose with dependencies.

       

      Everytime the ObjectMapper is instanitated I get:

       

       

      13:08:43,024 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/api/testservice]] (http-localhost-127.0.0.1-8080-1) StandardWrapper.Throwable: java.lang.RuntimeException: Unable to instantiate ContextResolver

          at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:838) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:743) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyDeployment.registerProvider(ResteasyDeployment.java:505) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:305) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:225) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

          at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_10]

      Caused by: java.lang.RuntimeException: Failed to construct public com.test.JacksonConfig() throws java.lang.Exception

          at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:144) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyProviderFactory.getProviderInstance(ResteasyProviderFactory.java:1039) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyProviderFactory.addContextResolver(ResteasyProviderFactory.java:620) [resteasy-jaxrs-2.3.2.Final.jar:]

          at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:834) [resteasy-jaxrs-2.3.2.Final.jar:]

          ... 19 more

      Caused by: java.lang.NoClassDefFoundError: org/codehaus/jackson/map/ObjectMapper

          at com.test.jackson.JacksonConfig.<init>(JacksonConfig.java:44) [common-0.0.1-SNAPSHOT.jar:]

          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_10]

          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_10]

          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_10]

          at java.lang.reflect.Constructor.newInstance(Constructor.java:525) [rt.jar:1.7.0_10]

          at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:132) [resteasy-jaxrs-2.3.2.Final.jar:]

          ... 22 more

      Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.map.ObjectMapper from [Module "deployment.testservice-ear.ear.testservice-war-0.0.1-SNAPSHOT.war:main" from Service Module Loader]

          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

          ... 28 more

       

      I suppose there is some problem with dependencies/wrong versions of jackson libraries are used.

       

       

      My pom contains:

       

       

      <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jackson-provider</artifactId>
      <version>2.3.2.Final</version>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <version>2.3.2.Final</version>
      <scope>provided</scope>
      </dependency>

       

      Now maven resolves among others the dependency jackson-mapper-asl of version 1.8.5 but as far as I understand JBoss 7.1.1 uses version 1.9.2 which may cause the stacktrace above.

       

      How can I resolve this issue?

       

      Sascha