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.