You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Guillaume Nodet (Jira)" <ji...@apache.org> on 2020/03/04 14:06:00 UTC

[jira] [Comment Edited] (CAMEL-14656) Unmarshal using ref is not working when upgrading to camel 3.1

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

Guillaume Nodet edited comment on CAMEL-14656 at 3/4/20, 2:05 PM:
------------------------------------------------------------------

The syntax with the {{ref}} attribute was deprecated. You should now use

{{<marshal><custom ref="xstream-default"/></marshal>}}

 

And I agree the error is a bit misleading, it can be improved here.


was (Author: gnt):
The syntax with the {{ref}} attribute was deprecated. You should now use

{{<marshal><custom ref="xstream-default"/></marshal>}}

> Unmarshal using ref is not working when upgrading to camel 3.1
> --------------------------------------------------------------
>
>                 Key: CAMEL-14656
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14656
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-xstream
>    Affects Versions: 3.1.0
>         Environment: Camel 3.1.0
>            Reporter: Mattias Andersson
>            Priority: Critical
>
> Hi,
> In Camel we use  route that looks like this:
>  
> {code:java}
> <route
> ....
> <unmarshal ref="xstream-default" />    <-- This does not work anymore
>    <dynamicRouter>        
>   <method method="route" ref="dynamicRouter" />    </dynamicRouter>         
> <marshalref="xstream-default" />
> ....
> </route>{code}
>   
>  
> We registered the "xstream-default" in the camel context. 
>  
> {code:java}
> XStreamDataFormat xD = new XStreamDataFormat();
> xD.setPermissions("*");
> xD.setEncoding("UTF8");
> dataFormats.put("xstream-default", xD);
> {code}
> {code:java}
> camelContext.setDataFormats(dataFormats);
> {code}
> and loads the xml using:
>  
> {code:java}
> try (InputStream is = EventRouteTree.toInputStream(doc)) {
>   RoutesDefinition routes = (RoutesDefinition) camelContext.getXMLRoutesDefinitionLoader()
>             .loadRoutesDefinition(camelContext, is);        
>    routes.getRoutes().forEach(r -> {
>           camelContext.addRouteDefinition(r);
>    });     
>  }
> {code}
>  
>  
> This worked fine i Camel 2.x but doesn't work in Camel 3.1 anymore. Tried to look at the upgrade 2.x to 3.0 guide but I found nothing specific regarding unmarshal. 
> According to the xsd it look like there is no "ref" anymore for the unmarshal defintion .
> [https://camel.apache.org/schema/spring/camel-spring-3.1.0.xsd]
>  
> I get the error when camel tries to start the route.
>  
> {code:java}
> Caused by: java.lang.IllegalArgumentException: ref or type must be specified at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:152) at org.apache.camel.reifier.dataformat.DataFormatReifier.getDataFormat(DataFormatReifier.java:164)
> {code}
> Which looks strange because the ref is defined in xml tag unmarshal. 
> So i guess since the xsd doesn't allow for a ref then the parser ignores the ref and it is empty when the code below is executed. Is this bug or are we suppose to define this in another way in the XML?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)