Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-11967

Restlet binding should not create jaxb marshaller when binding mode is set to json

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.20.0
    • 2.19.4, 2.20.1, 2.21.0
    • camel-core, rest
    • None
    • Patch Available
    • Unknown

    Description

      The following rest endpoint fails with jaxb exception:

      .get("/getAllEndpoints").bindingMode(RestBindingMode.json).outType(Map.class)
              			.to("bean:IRWebServiceRegistry?method=getAllProperties");
      
      Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
      java.util.Map is an interface, and JAXB can't handle interfaces.
      

      This is fine if i wanted to marshall to xml but i specifically set binding mode to json.

      Fix:
      Change this line:
      https://github.com/apache/camel/blob/36039c0563dfe9e04527c5eca1058e66326054ee/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java#L174

      To:
      if (jaxb != null && (mode.contains("xml") || mode.equals(RestBindingMode.auto))) {

      May want to consider doing the same for the json section at line 130

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            transamericamoon john
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: