camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willem Jiang (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (CAMEL-3865) FallbackTypeConverter method throws JAXBException when marshalling nested, non-ObjectFactory, JAXB annotated, classes
Date Fri, 15 Apr 2011 07:52:05 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-3865?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020210#comment-13020210
] 

Willem Jiang edited comment on CAMEL-3865 at 4/15/11 7:50 AM:
--------------------------------------------------------------

Hi,

The FallbackTypeConverter just create a JAXB context based on the type class that is annotated
with @XmlRootElement,the jaxb context doesn't has all the packages class, but JAXB will add
all the types thats relates to this types class.
I just committed [a small unit test|http://svn.apache.org/viewvc?rev=1092615&view=rev]
to reproducer the error, but I had no luck with it. Maybe you can consider to add some annotation
to work around this issue.

If you want to camel marshal and unmarshal the data rightly, you can use JAXB data format
directly, and you can set up other JAXB context options that you want.
Here is the example:
{code}
      <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:marshal"/>
            <marshal>
                <jaxb prettyPrint="false" contextPath="org.apache.camel.example"
                    partClass="org.apache.camel.example.PurchaseOrder"
                    partNamespace="{http://example.camel.org/apache}po" />
            </marshal>
            <to uri="mock:marshal"/>
        </route>
        <route>
            <from uri="direct:unmarshal"/>
            <unmarshal>
                <jaxb prettyPrint="false" contextPath="org.apache.camel.example"
                    partClass="org.apache.camel.example.Partial" />
            </unmarshal>
            <to uri="mock:unmarshal"/>
        </route>
    </camelContext> 
{code}

      was (Author: njiang):
    Hi,

The FallbackTypeConverter just create a JAXB context based on the type class that is annotated
with @XmlRootElement,the jaxb context doesn't has all the packages class, but JAXB will add
all the types thats relates to this types class.
I just committed [a small unit test|http://svn.apache.org/viewvc?rev=1092615&view=rev
] to reproducer the error, but I had no luck with it. Maybe you can consider to add some annotation
to work around this issue.

If you want to camel marshal and unmarshal the data rightly, you can use JAXB data format
directly, and you can set up other JAXB context options that you want.
Here is the example:
{code}
      <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:marshal"/>
            <marshal>
                <jaxb prettyPrint="false" contextPath="org.apache.camel.example"
                    partClass="org.apache.camel.example.PurchaseOrder"
                    partNamespace="{http://example.camel.org/apache}po" />
            </marshal>
            <to uri="mock:marshal"/>
        </route>
        <route>
            <from uri="direct:unmarshal"/>
            <unmarshal>
                <jaxb prettyPrint="false" contextPath="org.apache.camel.example"
                    partClass="org.apache.camel.example.Partial" />
            </unmarshal>
            <to uri="mock:unmarshal"/>
        </route>
    </camelContext> 
{code}
  
> FallbackTypeConverter method throws JAXBException when marshalling nested, non-ObjectFactory,
JAXB annotated, classes
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-3865
>                 URL: https://issues.apache.org/jira/browse/CAMEL-3865
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jaxb
>    Affects Versions: 2.7.0
>            Reporter: Clifton Eaton
>
> 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
>  

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message