Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org/codehaus/jackson/map/ObjectMapper.setSerializationInclusion exception in WAS server

we are working on java rest web service we are using the below jars

jackson-mapper-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-core-asl-1.9.2.jar
jackson-xc-1.9.2.jar
org.json-20120521.jar

Using the above jars below code is working fine in tomcat server.

ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Inclusion.NON_NULL);
String userJsonString = mapper.writeValueAsString(userJSON);
JSONObject userJsonObj = new JSONObject(userJsonString);

While deploying this in WAS server we have got the below error:

Error 500: javax.servlet.ServletException: java.lang.NoSuchMethodError: org/codehaus/jackson/map/ObjectMapper.setSerializationInclusion(Lorg/codehaus/jackson/map/annotate/JsonSerialize$Inclusion&#59;)Lorg/codehaus/jackson/map/ObjectMapper&#59;
like image 754
user2210071 Avatar asked Jun 24 '26 09:06

user2210071


1 Answers

From the jars it looks like you are using codehaus jackson: https://github.com/codehaus/jackson/ instead of fasterxml jackson: https://github.com/FasterXML/jackson. With codehaus jackson your code will look like: objectMapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL)

like image 76
ankitkpd Avatar answered Jun 26 '26 23:06

ankitkpd