1 Reply Latest reply on Feb 27, 2013 4:50 AM by mrychly

    Jboss 7.1.1 - Jackson ContextResolver<ObjectMapper> and staxon works properly only on one deployment

    mrychly

      I have two rest webapps I want to deploy on Jboss 7.1.1. server. Rest requests in both apps produces and consumes Json.

      At first I used jackson provider to serialize and deserialize objects. I needed custom ObjectMapper configurations for each webapp. So to resolve this problem I added @Provider classes implementing ContextResolver. One for each project. For example, one of my class looks like that:

       

      @provider
      @Produces(MediaType.APPLICATION_JSON)
      @Consumes(MediaType.APPLICATION_JSON)
      public class JacksonConfig implements ContextResolver<ObjectMapper> {
         private final ObjectMapper objectMapper;
         public JacksonConfig()
         {
             objectMapper = new ObjectMapper();
             objectMapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
         }
         @Override
         public ObjectMapper getContext(Class<?> objectType) {
             return objectMapper;
         }
      }

       

      It works well when I deploy only one of this projects on jboss. When I try to deploy both, only first initialized project use defined objectMapper. Other one never called getContext method from ContextResolver class.

       

      To avoid this problem, i decided to try with staxon...

      I hoped that at least this method will work well. But not... Serialization works perfectly on both deployed applications. But again, somehow jboss decided to use jackson instead of staxon in deserialization process. Again always application which I call first after deployment works well. But Second one using jackson (no idea why ????) which calls exceptions. Always...

      Is it possible that it's a problem with Jboss? Probably I'm just doing something wrong but I have no idea where. Anybody has idea where should I look?

      Only jettison works properly, but it has some 'featchures' ( such as skipping '[', ']' for one element Lists or parsing strings containing only numbers f.e.  "1111" to integer ) which are little annoying.


        • 1. Re: Jboss 7.1.1 - Jackson ContextResolver<ObjectMapper> and staxon works properly only on one deployment
          mrychly

          I found solution for this problem. It was known issue of resteasy, that can be removed by build-in option:

          To solve this problem I just had to add param to web.xml of my projects:

               <context-param>
                   <param-name>resteasy.use.deployment.sensitive.factory</param-name>
                   <param-value>false</param-value>
               </context-param>

           

          By the way I found this solution in resteasy jira, It's little strange for me that there is no info about such problem in resteasy related documentations...