0 Replies Latest reply on Dec 1, 2016 2:34 PM by Diego Nieto Cid

    Custom Type Converter isn't loaded

    Diego Nieto Cid Newbie



      I'm following the Get Started page[1] to create a Fuse application based

      on the Camel Content Based Router example.


      So, I started working on the pipeline and the need for a custom type

      converter arose.


      Following the 45.2 of Camel's developers guide[2], I created a class with

      a static method for the conversion, both annotated with @Converter.


      package typeconverters;
      import java.util.List;
      import org.apache.camel.Converter;
      import org.apache.camel.Exchange;
      import dto.LineItem;
      public final class LineItemConverter {
          private LineItemConverter() {}
          public static LineItem fromListOfStrings(List<String> from, Exchange ex) {
              return new LineItem(); /* TODO: implement */


      Then, I created a file named TypeConverter under the directory

      `src/main/resources/META-INF/services/org/apache/camel`. The file contains just

      one line reading `typeconverters`.


      Finally, I deploy to the server and start it, as documented in [1]. I put some

      files in the input folder and bam! an exception is thrown:


      org.apache.camel.InvalidPayloadException: No body available of type: dto.LineItem but has value: [...]
        at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:107)[232:org.apache.camel.camel-core:2.17.0.redhat-630187]
      Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.util.ArrayList to the required type: dto.LineItem with value...


      The developer guide said something about putting the JAR containing the converter

      in the classpath. But I don't really want to separate the converter from the fuse app.


      Any ideas?





      [1] JBoss Fuse - Get Started | Red Hat Developers

      [2] https://access.redhat.com/documentation/en/red-hat-jboss-fuse/6.3/paged/apache-camel-development-guide/chapter-45-type-c…



        * JBoss Fuse: 6.3.0.redhat-187

        * JBoss Developer Studio: 10.0.0.GA-standalone-installer

        * Apache Camel: 2.17.0.redhat-630187