I was unable to set the guidewire ObjectMapper via configuration. The "good enough" solution I arrived at is thus: in the route class extending GwRouteBuilder
@Inject
private ObjectMapper jacksonObjectMapper; //ObjectMapper from Spring
In the configure() method:
JacksonDataFormat jacksonDataFormat = new JacksonDataFormat();
jacksonDataFormat.setObjectMapper(jacksonObjectMapper);
jacksonDataFormat.setCamelContext(getCamelContext());
In the route definitions when serializing the body, instead of using:
.marshal().json() //marshal body object to json
use:
.marshal(jacksonDataFormat) //transform body into json string using custom dataformat
This has the added benefit of having the injected object mapper available for deserializing, i.e.
String s=exchange.getMessage().getBody(String.class);
Whatever parsed=jacksonObjectMapper.readValue(s, Whatever.class);