You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nav <na...@yahoo.com> on 2010/07/16 11:20:19 UTC

org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.util.HashMap to the required type: org.apache.xmlbeans.XmlObject

Hi,
     I am using XMLBeans in my route for marshalling an object into XML.  I
get the following error.
SEVERE: Caused by: [org.apache.camel.NoTypeConversionAvailableException - No
type converter available to convert from type: java.util.HashMap to the
required type: org.apache.xmlbeans.XmlObject 

 In the DTO there is HashMap field, which requires a type converter. 


@XmlRootElement(name = "ShippingConditions")
@XmlAccessorType(XmlAccessType.PROPERTY)
public class ShippingConditionMapDTO {

    Map<String,List<ShippingCondition>> shippingConditionMap = new
HashMap<String, List<ShippingCondition>>();

  
    public Map<String, List<ShippingCondition>> getShippingConditionMap() {
        return shippingConditionMap;
    }

    public void setShippingConditionMap(Map<String, List<ShippingCondition>>
shippingConditionMap) {
        this.shippingConditionMap = shippingConditionMap;
    }
}

 The route is as follows.  The Processor returns an instance of the DTO
mentioned above.

 <route>
           <from uri="{{CSVFileFolder}}"/>
            <convertBodyTo type="java.lang.String"/>
            <process ref="shippingConditionProcessor"/>
            <marshal><xmlBeans/></marshal>
            <convertBodyTo type="java.lang.String"/>
            <setHeader headerName="CamelHttpMethod">
                <constant>POST</constant>
            </setHeader>
            <setHeader headerName="Content-Type">
                <constant>application/xml</constant>
            </setHeader>
          <to uri="http://testserver/shippingCondition"/>   
         </route>

How can I specify typeconverter for this ? 

-- 
View this message in context: http://camel.465427.n5.nabble.com/org-apache-camel-NoTypeConversionAvailableException-No-type-converter-available-to-convert-from-typet-tp1223953p1223953.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.util.HashMap to the required type: org.apache.xmlbeans.XmlObject

Posted by James Strachan <ja...@gmail.com>.
On 16 July 2010 12:46, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> Do you need to use xmlbeans? I would suggest to try out JAXB or XStream instead.

I concur with Claus; XmlBeans is a bit sucky, JAXB/XStream is a little
better if you can use it.

Whatever you use though, you can write a method on a bean to do the
transformation yourself...

  <bean ref="myBeanName" method="doTransform"/>

Then write

class MyBean {
  public String doTransform(SomeType body) { ... }
}

Or if you want to install this conversion method into the type
converter registry and carry on using the <convertBodyTo/>, add
@Converter to the bean & method and add the package to those searched
by Camel on startup as described in "Writing your own Type Converters"
http://camel.apache.org/type-converter.html


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.util.HashMap to the required type: org.apache.xmlbeans.XmlObject

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Do you need to use xmlbeans? I would suggest to try out JAXB or XStream instead.


On Fri, Jul 16, 2010 at 11:20 AM, Nav <na...@yahoo.com> wrote:
>
> Hi,
>     I am using XMLBeans in my route for marshalling an object into XML.  I
> get the following error.
> SEVERE: Caused by: [org.apache.camel.NoTypeConversionAvailableException - No
> type converter available to convert from type: java.util.HashMap to the
> required type: org.apache.xmlbeans.XmlObject
>
>  In the DTO there is HashMap field, which requires a type converter.
>
>
> @XmlRootElement(name = "ShippingConditions")
> @XmlAccessorType(XmlAccessType.PROPERTY)
> public class ShippingConditionMapDTO {
>
>    Map<String,List<ShippingCondition>> shippingConditionMap = new
> HashMap<String, List<ShippingCondition>>();
>
>
>    public Map<String, List<ShippingCondition>> getShippingConditionMap() {
>        return shippingConditionMap;
>    }
>
>    public void setShippingConditionMap(Map<String, List<ShippingCondition>>
> shippingConditionMap) {
>        this.shippingConditionMap = shippingConditionMap;
>    }
> }
>
>  The route is as follows.  The Processor returns an instance of the DTO
> mentioned above.
>
>  <route>
>           <from uri="{{CSVFileFolder}}"/>
>            <convertBodyTo type="java.lang.String"/>
>            <process ref="shippingConditionProcessor"/>
>            <marshal><xmlBeans/></marshal>
>            <convertBodyTo type="java.lang.String"/>
>            <setHeader headerName="CamelHttpMethod">
>                <constant>POST</constant>
>            </setHeader>
>            <setHeader headerName="Content-Type">
>                <constant>application/xml</constant>
>            </setHeader>
>          <to uri="http://testserver/shippingCondition"/>
>         </route>
>
> How can I specify typeconverter for this ?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/org-apache-camel-NoTypeConversionAvailableException-No-type-converter-available-to-convert-from-typet-tp1223953p1223953.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus