Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8402627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:07:14+00:00 2026-06-09T22:07:14+00:00

I am using Apache Camel 2.9.2 and Spring 3.0.6.RELEASE. I am trying to use

  • 0

I am using Apache Camel 2.9.2 and Spring 3.0.6.RELEASE. I am trying to use a custom DataFormat to marshal and unmarshal Camel messages. I want to configure my custom DataFormat into one of my routes using Spring.

Apache Camel’s documentation states that in order to hook up my custom Data Format to a route in Spring I simply need to declare my custom DataFormat as a bean and reference it inside of my Spring route like so:

<marshal>
    <custom ref="myCustomDataFormat"/>
</marshal>

http://camel.apache.org/custom-dataformat.html

So I have the following setup:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-3.0.xsd
">

<bean id="myCustomDataFormat" class="com.test.CustomDataFormat"/>
<!-- Camel Context -->
<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route>
        <from uri="file:C:/test?initialDelay=4000&amp;delay=1000"/>
        <marshal>
            <custom ref="myCustomDataFormat"/>
        </marshal>
        <to uri="file:C:/test2"/>
    </route>
</camelContext>
</beans>

But when I try to start Camel, I get the following nasty error:

org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type ‘com.test.CustomDataFormat’ to required type ‘org.apache.camel.model.DataFormatDefinition’; nested exception is java.lang.IllegalStateException: Cannot convert value of type [com.test.CustomDataFormat] to required type [org.apache.camel.model.DataFormatDefinition]: no matching editors or conversion strategy found

My Data Format is defined as follows:

package com.test;

import java.io.InputStream;
import java.io.OutputStream;

import org.apache.camel.Exchange;
import org.apache.camel.spi.DataFormat;

public class CustomDataFormat implements DataFormat {

/* (non-Javadoc)
 * @see org.apache.camel.spi.DataFormat#marshal(org.apache.camel.Exchange, java.lang.Object, java.io.OutputStream)
 */
@Override
public void marshal(Exchange exchange, Object graph, OutputStream stream)
        throws Exception {
    System.out.println("Marshal");
    byte[] bytes = exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, graph);
    stream.write(bytes);

}

/* (non-Javadoc)
 * @see org.apache.camel.spi.DataFormat#unmarshal(org.apache.camel.Exchange, java.io.InputStream)
 */
@Override
public Object unmarshal(Exchange exchange, InputStream stream)
        throws Exception {
    System.out.println("Unmarshal");
    byte[] bytes = exchange.getContext().getTypeConverter().mandatoryConvertTo(byte[].class, stream);
    return bytes;
}
}

I know that my CustomDataFormat implementation is correct because I created the following test route in Java and it worked flawlessly

package com.test;

import org.apache.camel.spring.SpringRouteBuilder;

public class TestFormatRoute extends SpringRouteBuilder {

/* (non-Javadoc)
 * @see org.apache.camel.builder.RouteBuilder#configure()
 */
@Override
public void configure() throws Exception {
    from("file:C:/test?initialDelay=4000&delay=1000").unmarshal(new CustomDataFormat()).to("file:C:/test2");
}

}

What am I missing?

Thanks

Update

After letting Camel completely start up after receiving this error I found to my disbelief that my custom data format actually does work in the route that I created. I’m not sure what process is attempting to parse my custom data format and failing but it is apparently not the same process parsing the data format to put into my route.

This solves the functional requirement of the data format, but it does not explain why I am receiving this error.

I have also confirmed that it was not the name of my data format (CustomDataFormat) that was causing the issue. Renaming my DataFormat to a unique name (MerlinDataFormat) did not fix the error.

I still would like to know why I am receiving this error since large blocks of ugly red errors in my console and log files aren’t exactly appealing.

Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:07:16+00:00Added an answer on June 9, 2026 at 10:07 pm

    It turned out to be a pretty simple solution (and one that I admit should have been easy to see). There are actually two ways to go about solving this issue, one of them using only spring and one of them requiring an additional java class.

    Solution 1

    Create a new class extending DataFormatDefinition which has the same properties as your custom DataFormat. Override the configureDataFormat() method to set all of the properties of the underlying DataFormat. Add constructor(s) to set the underlying DataFormat as an instance of your CustomDataFormat. Now you should be able to create an instance of your DataFormatDefinition in spring and reference it when marshaling or unmarshaling.

    Solution 2 (Quick & Dirty)

    In spring, create a new DataFormatDefinition bean and set it’s dataFormat property as a reference to your DataFormat spring bean. Now you should be able to reference your DataFormatDefinition bean when marshaling or unmarshaling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate Google Places API using Apache Camel (2.10-SNAPSHOT) and Spring (3.0.7.RELEASE)
I'm trying to use Spring AsyncServlet with Camel and ActiveMQ. I'm using the following
I am building a proof of concept for using Apache Camel. I am trying
I'm trying to expose a web service using fuse esb + apache camel +
I'm trying to run the Camel Example camel-example-spring-jms (also at http://activemq.apache.org/camel/tutorial-jmsremoting.html ). However, when
In my application build using apache camel (mavenized, spring dsl) , i am reading
I am integrating data between two systems using Apache Camel. I want the resulting
I was trying to materialize apache Camel project in my eclipse environment. I'm using
I'm using Apache camel to route some SOAP messages from A to B. I'd
How can I do multipart file uploads using the Apache Camel HTTP component ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.