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

FallbackTypeConverter method throws JAXBException when marshalling nested, non-ObjectFactory, JAXB annotated, classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • 2.7.0
    • None
    • camel-jaxb
    • None

    Description

      FallbackTypeConverter method throws JAXBException when marshalling nested, non-ObjectFactory, JAXB annotated, classes. These are classes that are annotated with the @XmlRootElement, but not generated using XJC, so there is no ObjectFactory class for them. The intention is to provide the package names containing the jaxb.index files to build the context.

      FallbackTypeConverter does not marshal or unmarshal using the package names, but rather uses the value's Class as the context. Thus everytime a JAXB annotated object contains another JAXB annotated object, there is an exception that looks like this:

      Caused by: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: com.foo.bar.MyObject@15e6463]
      at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1155)
      at org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(FallbackTypeConverter.java:93)
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:190)
      at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:101)
      at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:73)
      at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47)
      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:115)
      at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:103)
      at org.apache.camel.component.bean.BeanProcessor.process(BeanProcessor.java:74)
      at org.apache.camel.language.bean.BeanExpression$InvokeProcessor.process(BeanExpression.java:136)
      ... 39 more
      Caused by: javax.xml.bind.MarshalException

      • with linked exception:
        [javax.xml.bind.JAXBException: class com.foo.bar.nested.MyNested nor any of its super class is known to this context.]
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
        at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96)
        at org.apache.camel.converter.jaxb.FallbackTypeConverter.marshall(FallbackTypeConverter.java:174)
        at org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(FallbackTypeConverter.java:88)
        ... 47 more
        Caused by: javax.xml.bind.JAXBException: class com.foo.bar.nested.MyNested nor any of its super class is known to this context.
        at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:246)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:261)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:653)
        at com.sun.xml.bind.v2.runtime.property.SingleMapNodeProperty.serializeBody(SingleMapNodeProperty.java:272)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)
        at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:324)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
        at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
        ... 51 more
        Caused by: javax.xml.bind.JAXBException: class com.foo.bar.nested.MyNested nor any of its super class is known to this context.
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:594)
        at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:648)
        ... 57 more

      Attachments

        Activity

          People

            njiang Willem Jiang
            eagecl Clifton Eaton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: