You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Amruta Jawlekar <am...@ignitiv.com> on 2017/02/23 12:06:37 UTC

Error in Unmarshalling to custom data format

I am getting error in unmarshalling to custom data format. It is working
successfully in Java DSL approach, now I need to convert it in Spring DSL
where I am getting error.

camel-context.xml

<bean id="wynFlatFileDataFormat"
class="ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat" />

<camelContext trace="true"
		xmlns="http://camel.apache.org/schema/spring">

		<camel:route id="processInputFile">
			<camel:from uri="direct:processFileImport"/>
				<camel:unmarshal>
					<camel:custom ref="wynFlatFileDataFormat"/>
				</camel:unmarshal>
			<camel:to uri="direct:generateOutput" />
		</camel:route>

</camelContext>

WynFlatFileDataFormat - 

public class WynFlatFileDataFormat extends ServiceSupport implements
DataFormat, IWynIntegrationConstants {
public Map<String, WynFlatFileDefinitionBean> unmarshal(Exchange exchange,
InputStream stream) throws Exception {
  // processing stream data and putting in a Map<String,
WynFlatFileDefinitionBean> taskBeanMap.
  // returning taskBeanMap
}
}

WynFlatFileDefinitionBean -
public class WynFlatFileDefinitionBean implements Serializable {
   // getters and setters
}


Error trace -

[                          main] DefaultListableBeanFactory     DEBUG
Returning cached instance of singleton bean 'wynFlatFileDataFormat'
[                          main] BeanUtils                      DEBUG No
property editor [org.apache.camel.model.DataFormatDefinitionEditor] found
for type org.apache.camel.model.DataFormatDefinition according to 'Editor'
suffix convention
[                          main] DefaultListableBeanFactory     DEBUG Failed
to convert bean 'wynFlatFileDataFormat' to required type
[org.apache.camel.model.DataFormatDefinition]
org.springframework.beans.ConversionNotSupportedException: Failed to convert
value of type
[ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
required type [org.apache.camel.model.DataFormatDefinition]; nested
exception is java.lang.IllegalStateException: Cannot convert value of type
[ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
required type [org.apache.camel.model.DataFormatDefinition]: no matching
editors or conversion strategy found
	at
org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:74)[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
.
.
.
.
.
Exception in thread "main" org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route
processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in route:
Route(processItemDimensionFile)[[From[direct:processItemDime... because of
Either packages or classType must be specified
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
	at
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at
org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:213)
	at org.apache.camel.spring.Main.doStart(Main.java:153)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
ign.wyn.integration.initiator.WynImportInitiator.main(WynImportInitiator.java:32)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
route processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in
route: Route(processItemDimensionFile)[[From[direct:processItemDime...
because of Either packages or classType must be specified
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
	at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3301)
	at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3024)
	at
org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
	at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2854)
	at
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2850)
	at
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2873)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2850)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2819)
	at
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
	... 13 more
Caused by: java.lang.IllegalArgumentException: Either packages or classType
must be specified
	at
org.apache.camel.model.dataformat.BindyDataFormat.createDataFormat(BindyDataFormat.java:98)
	at
org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:103)
	at
org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:78)
	at
org.apache.camel.model.MarshalDefinition.createProcessor(MarshalDefinition.java:177)
	at
org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534)
	at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495)
	at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)
	at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
	... 26 more


Working Java DSL Statement for the same -
from("direct:processFileImport").unmarshal(new
WynFlatFileDataFormat()).to("direct:splitData");

Would appreciate any help! 

Thanks,
Amruta 



--
View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error in Unmarshalling to custom data format

Posted by Amruta Jawlekar <am...@ignitiv.com>.
Thanks a lot Tomohisa, I was able to fix the issue after putting a debug in
the DataFormatDefinition. 
The dataformat bean was not correctly referenced in the route.

And yes, as you said.. The error for java.lang.IllegalStateException does
not mean anything :)



--
View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794377.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error in Unmarshalling to custom data format

Posted by Tomohisa Igarashi <tm...@gmail.com>.
Hi,

On 02/24/2017 01:36 PM, Amruta Jawlekar wrote:
> Thanks for your reply, Allan.
>
> Now I have removed all the routes from camel-context which were using bindy.
> So the bindy error message is gone. However, the main error in data
> conversion (unmarshalling) is still there.
>
> [                          main] BeanUtils                      DEBUG No
> property editor [org.apache.camel.model.DataFormatDefinitionEditor] found
> for type org.apache.camel.model.DataFormatDefinition according to 'Editor'
> suffix convention
> [                          main] DefaultListableBeanFactory     DEBUG Failed
> to convert bean 'wynFlatFileDataFormat' to required type
> [org.apache.camel.model.DataFormatDefinition]
> org.springframework.beans.ConversionNotSupportedException: Failed to convert
> value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]; nested
> exception is java.lang.IllegalStateException: Cannot convert value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]: no matching
> editors or conversion strategy found

Does this DEBUG log really mean any problem? Doesn't it succeed right after this by resolving DataFormat instance directly?

When 'ref' is specified Camel first tries to resolve DataFormatDefinition with that name:
https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/model/DataFormatDefinition.java#L78

But if it fails, then try again to resolve DataFormat instance with that name here:
https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/model/DataFormatDefinition.java#L84

You may want to set a breakpoint around there and see what's actually happening.

Thanks,
Tomo

Re: Error in Unmarshalling to custom data format

Posted by Amruta Jawlekar <am...@ignitiv.com>.
I will define the data format as per the link that you've given, and update
the forum. Thanks for the prompt response.



--
View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794373.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error in Unmarshalling to custom data format

Posted by "Allan C." <al...@gmail.com>.
I could be wrong, but I think the error message is saying you have not
specified what type of format you would want to marshal/unmarshal it
into/from. Thus I think you would need to define the data formats, if you
haven't already done that.

http://camel.apache.org/data-format.html#DataFormat-UsingSpringXML

Regards,
Allan C.

On 24 February 2017 at 12:36, Amruta Jawlekar <am...@ignitiv.com> wrote:

> Thanks for your reply, Allan.
>
> Now I have removed all the routes from camel-context which were using
> bindy.
> So the bindy error message is gone. However, the main error in data
> conversion (unmarshalling) is still there.
>
> [                          main] BeanUtils                      DEBUG No
> property editor [org.apache.camel.model.DataFormatDefinitionEditor] found
> for type org.apache.camel.model.DataFormatDefinition according to 'Editor'
> suffix convention
> [                          main] DefaultListableBeanFactory     DEBUG
> Failed
> to convert bean 'wynFlatFileDataFormat' to required type
> [org.apache.camel.model.DataFormatDefinition]
> org.springframework.beans.ConversionNotSupportedException: Failed to
> convert
> value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]; nested
> exception is java.lang.IllegalStateException: Cannot convert value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]: no matching
> editors or conversion strategy found
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794371.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Error in Unmarshalling to custom data format

Posted by Amruta Jawlekar <am...@ignitiv.com>.
Thanks for your reply, Allan.

Now I have removed all the routes from camel-context which were using bindy.
So the bindy error message is gone. However, the main error in data
conversion (unmarshalling) is still there. 

[                          main] BeanUtils                      DEBUG No
property editor [org.apache.camel.model.DataFormatDefinitionEditor] found
for type org.apache.camel.model.DataFormatDefinition according to 'Editor'
suffix convention
[                          main] DefaultListableBeanFactory     DEBUG Failed
to convert bean 'wynFlatFileDataFormat' to required type
[org.apache.camel.model.DataFormatDefinition]
org.springframework.beans.ConversionNotSupportedException: Failed to convert
value of type
[ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
required type [org.apache.camel.model.DataFormatDefinition]; nested
exception is java.lang.IllegalStateException: Cannot convert value of type
[ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
required type [org.apache.camel.model.DataFormatDefinition]: no matching
editors or conversion strategy found




--
View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794371.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error in Unmarshalling to custom data format

Posted by "Allan C." <al...@gmail.com>.
I have limited experience in Bindy, but referring to the error message, it
seems that the dataFormats section is not specified in the camel context,
or does not have its properties specified.

Also, before a certain version (I can't remember which), there's a
limitation where Bindy can only recognize a single POJO/data file format in
one package. So if said version is being used, the POJOs need to be in
separate packages.

Latest 2.18.x allows you to define bindy POJOs in a single package.

Regards,
Allan C.

On 23 February 2017 at 21:07, Amruta Jawlekar <am...@ignitiv.com> wrote:

> Actually, bindy is used for marshalling data in the latter step/route. But
> i
> have commented that route for now and jumped to the last route. So the code
> which deals with Bindy is all commented.
>
> Not sure why this below error comes up because the processItemDimensionFile
> route is commented and not in the path of current route.
>
> Failed to create route
> > processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in
> > route:
> > Route(processItemDimensionFile)[[From[direct:processItemDime... because
> of
> > Either packages or classType must be specified
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794347.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Error in Unmarshalling to custom data format

Posted by Amruta Jawlekar <am...@ignitiv.com>.
Actually, bindy is used for marshalling data in the latter step/route. But i
have commented that route for now and jumped to the last route. So the code
which deals with Bindy is all commented. 

Not sure why this below error comes up because the processItemDimensionFile
route is commented and not in the path of current route.

Failed to create route 
> processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in
> route: 
> Route(processItemDimensionFile)[[From[direct:processItemDime... because of 
> Either packages or classType must be specified 




--
View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344p5794347.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Error in Unmarshalling to custom data format

Posted by Claus Ibsen <cl...@gmail.com>.
The error is from bindy data format, so somewhere you must be using
that, and you have not configured bindy correct

On Thu, Feb 23, 2017 at 1:06 PM, Amruta Jawlekar <am...@ignitiv.com> wrote:
> I am getting error in unmarshalling to custom data format. It is working
> successfully in Java DSL approach, now I need to convert it in Spring DSL
> where I am getting error.
>
> camel-context.xml
>
> <bean id="wynFlatFileDataFormat"
> class="ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat" />
>
> <camelContext trace="true"
>                 xmlns="http://camel.apache.org/schema/spring">
>
>                 <camel:route id="processInputFile">
>                         <camel:from uri="direct:processFileImport"/>
>                                 <camel:unmarshal>
>                                         <camel:custom ref="wynFlatFileDataFormat"/>
>                                 </camel:unmarshal>
>                         <camel:to uri="direct:generateOutput" />
>                 </camel:route>
>
> </camelContext>
>
> WynFlatFileDataFormat -
>
> public class WynFlatFileDataFormat extends ServiceSupport implements
> DataFormat, IWynIntegrationConstants {
> public Map<String, WynFlatFileDefinitionBean> unmarshal(Exchange exchange,
> InputStream stream) throws Exception {
>   // processing stream data and putting in a Map<String,
> WynFlatFileDefinitionBean> taskBeanMap.
>   // returning taskBeanMap
> }
> }
>
> WynFlatFileDefinitionBean -
> public class WynFlatFileDefinitionBean implements Serializable {
>    // getters and setters
> }
>
>
> Error trace -
>
> [                          main] DefaultListableBeanFactory     DEBUG
> Returning cached instance of singleton bean 'wynFlatFileDataFormat'
> [                          main] BeanUtils                      DEBUG No
> property editor [org.apache.camel.model.DataFormatDefinitionEditor] found
> for type org.apache.camel.model.DataFormatDefinition according to 'Editor'
> suffix convention
> [                          main] DefaultListableBeanFactory     DEBUG Failed
> to convert bean 'wynFlatFileDataFormat' to required type
> [org.apache.camel.model.DataFormatDefinition]
> org.springframework.beans.ConversionNotSupportedException: Failed to convert
> value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]; nested
> exception is java.lang.IllegalStateException: Cannot convert value of type
> [ign.wyn.integration.common.dataformat.csv.WynFlatFileDataFormat] to
> required type [org.apache.camel.model.DataFormatDefinition]: no matching
> editors or conversion strategy found
>         at
> org.springframework.beans.TypeConverterSupport.doConvert(TypeConverterSupport.java:74)[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
> .
> .
> .
> .
> .
> Exception in thread "main" org.apache.camel.RuntimeCamelException:
> org.apache.camel.FailedToCreateRouteException: Failed to create route
> processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in route:
> Route(processItemDimensionFile)[[From[direct:processItemDime... because of
> Either packages or classType must be specified
>         at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1690)
>         at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
>         at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)
>         at
> org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
>         at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
>         at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:381)
>         at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:335)
>         at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:855)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541)
>         at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
>         at
> org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
>         at
> org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:213)
>         at org.apache.camel.spring.Main.doStart(Main.java:153)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>         at
> ign.wyn.integration.initiator.WynImportInitiator.main(WynImportInitiator.java:32)
> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create
> route processItemDimensionFile at: >>> Marshal[ref:wynCsvDataFormat] <<< in
> route: Route(processItemDimensionFile)[[From[direct:processItemDime...
> because of Either packages or classType must be specified
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)
>         at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3301)
>         at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3024)
>         at
> org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
>         at
> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2854)
>         at
> org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2850)
>         at
> org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2873)
>         at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2850)
>         at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
>         at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2819)
>         at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)
>         at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
>         ... 13 more
> Caused by: java.lang.IllegalArgumentException: Either packages or classType
> must be specified
>         at
> org.apache.camel.model.dataformat.BindyDataFormat.createDataFormat(BindyDataFormat.java:98)
>         at
> org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:103)
>         at
> org.apache.camel.model.DataFormatDefinition.getDataFormat(DataFormatDefinition.java:78)
>         at
> org.apache.camel.model.MarshalDefinition.createProcessor(MarshalDefinition.java:177)
>         at
> org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:534)
>         at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:495)
>         at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:219)
>         at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
>         ... 26 more
>
>
> Working Java DSL Statement for the same -
> from("direct:processFileImport").unmarshal(new
> WynFlatFileDataFormat()).to("direct:splitData");
>
> Would appreciate any help!
>
> Thanks,
> Amruta
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Error-in-Unmarshalling-to-custom-data-format-tp5794344.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2