JSON Marshaller does not respect JAXB annotations

Solution Verified - Updated -

Issue

When using the JSON Marshaller to construct a payload to create a BPM process, then the JAXB annotations are not respected.

Using this method:

public String createBPM(ProcessorData data) {

    HashSet<Class<?>> classes = new HashSet<Class<?>>();
    classes.add(ProcessorData.class);

    Marshaller marshaller = MarshallerFactory.getMarshaller(classes, MarshallingFormat.JSON, getClass().getClassLoader());

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("inProcessorData", data);

    return marshaller.marshall(map);
}

Produces a payload where JAXB annotations inside ProcessorData are simply not present. For example, if JAXB annotation is overriding an attribute name, then this attribute name won't be changed in the final JSON payload.

Environment

  • Red Hat JBoss BPM Suite
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.