You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jeff <jf...@gmail.com> on 2013/02/25 17:32:49 UTC

A little problem with annotation @CsvRecord

Hey ! 

I am a newbie with this framework. I am designing a little
MAVEN/SPRING/CAMEL P.O.C.

( I hope I don't spam, I have already post by mail, put I am not really used
to nabble :) )
By the way, I don't understand why spring tell me : 

The separator has not been defined in the annotation @CsvRecord or not
instantiated during initModel. must be specified

I am using spring to initiate the prog : 

	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
		<package>com.mycomp.mediation.simpleExemple</package>
	</camelContext>

My main class just do : 

new ClassPathXmlApplicationContext("META-INF/spring/SpringBeans.xml");

I have a : 

 @CsvRecord(separator = ";" , crlf = "UNIX")
public class CSVLineFormatAED {
	@DataField(pos = 1)
	private String name  = "";
...
}

And a bindy route : 

public class BindyRoute extends RouteBuilder {
	@Override
	public void configure() throws Exception {

		BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat(
				"com.mycomp.mediation.simpleExemple.CSVLineFormatAED");

		
		from("file:C:/input/test.csv")
				.split(body().tokenize("\n"))
				.unmarshal(camelDataFormat)
				.bean(InportSimple.class)
		.to("mock:test")
				.end();
	}
}

Is anyone has a solution ? 

Thanks ! 



--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

Posted by Willem jiang <wi...@gmail.com>.
BindyCsvDataFormat supports to set the Class or the PackageName for it.
Did you have a chance to create a new BindyCsvDataFormat with below lines ?

BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat(
com.mycomp.mediation.simpleExemple.CSVLineFormatAED.class);


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Tuesday, February 26, 2013 at 3:49 AM, jeff wrote:

> Thanks @Claus for the help, but it don't works too...
>  
> I have found a solution which consist to retrieve the bean from the context
> from the routebuilder :
>  
> spring bean xml :  
> <bean id="cSVLineFormatAED" class="com.myapp...package.CSVLineFormatAED">
>  
>  
> @CsvRecord(separator = ";" , crlf = "UNIX")
> public class CSVLineFormatAED extends BindyCsvDataFormat {
> public CSVLineFormatAED() {
> super("com.myapp....package");
> }
> }
>  
> public class BindyRoute extends RouteBuilder {
>  
> @Override
> public void configure() throws Exception {
>  
> // Context Camel
> SpringCamelContext camelCtx = (SpringCamelContext) getContext();
>  
> // Context Spring
> ApplicationContext springCtx = camelCtx.getApplicationContext();
>  
> BindyCsvDataFormat camelDataFormatAED = (BindyCsvDataFormat) springCtx
> .getBean("cSVLineFormatAED");
>  
> from("file:C:/input/test.csv")
> .split(body().tokenize("\n"))
> .unmarshal(camelDataFormatAED)
> .to("mock:test").end();
> ...
> }
>  
> Hope it will be helpfull for other developper !  
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728119.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: A little problem with annotation @CsvRecord

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

If you deploy as WAR etc then you need to setup that jboss classloader
http://camel.apache.org/how-do-i-run-activemq-and-camel-in-jboss.html
http://camel.apache.org/camel-jboss.html

Bindy still requires this but we have a ticket to remove this need,
but this requires unfortunately a bit more work.
And as bindy works well on tomcat / jetty etc then its less people
having this trouble.

On Fri, Apr 17, 2015 at 5:07 AM, sanjay.gautam <sa...@gmail.com> wrote:
> HI Guys were you able to solve this problem , this problem is still lurking
> in camel code and now I am facing on the wildfly fly 8.2.0Final and also it
> doesn't work on other JBoss versions.
> Please let me know if you guys have any solution '
>
> Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------:
> java.lang.IllegalArgumentException: The separator h
>  not been defined in the annotation @CsvRecord or not instantiated during
> initModel. must be specified
>         at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:137)
> [camel-bindy-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
> [camel-core-2.15.0.jar:2.15.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
> [camel-core-2.15.0.jar:2.15.0]
>         at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:433)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
> [camel-core-2.15.0.jar:2.15.0]
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> [rt.jar:1.7.0_71]
>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5765883.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: A little problem with annotation @CsvRecord

Posted by "sanjay.gautam" <sa...@gmail.com>.
HI Guys were you able to solve this problem , this problem is still lurking
in camel code and now I am facing on the wildfly fly 8.2.0Final and also it
doesn't work on other JBoss versions. 
Please let me know if you guys have any solution '

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------:
java.lang.IllegalArgumentException: The separator h
 not been defined in the annotation @CsvRecord or not instantiated during
initModel. must be specified
        at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:137)
[camel-bindy-2.15.0.jar:2.15.0]
        at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:67)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
[camel-core-2.15.0.jar:2.15.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
[camel-core-2.15.0.jar:2.15.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:433)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
[camel-core-2.15.0.jar:2.15.0]
        at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
[camel-core-2.15.0.jar:2.15.0]
        at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[rt.jar:1.7.0_71]







--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5765883.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

Posted by wpeirone <wp...@gmail.com>.
Hi Claus,

Thanks for fast response. 
I tried outside osgi and works fine. I didn´t tried in Karaf (I have to
invest some time trying it).

I moved to camel-beanio and It´s working inside osgi too, so appears to be a
problem of bind with osgi.

I´m just starting with osgi stuffs, when I´ll could figure out the full
picture (or almost full) picture I´ll try to contribute if it´s really a bug
(i´m not sure if I was doing something wrong).

thank you very much,
Walter




--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5733960.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

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

Its hard to tell when its OSGi. If you have an unit test or run your
app outside OSGi and then see if it works.
Then you know its when you deploy and run in OSGi there is something "wrong".

And you can also try upgrading the Camel version / ESB version. Or try
patching the code yourself if there is a fix.

On Tue, Jun 4, 2013 at 10:35 PM, wpeirone <wp...@gmail.com> wrote:
> Hi guys,
>
> I´m using camel bindy 2.8.0-fuse-07-16  in equinox
> I tried some of the solutions in this post, but without good results.
>
> I´m still getting java.lang.IllegalArgumentException: The separator has not
> been defined in the annotation @CsvRecord or not instantiated during
> initModel. must be specified
>
> Last try was with getting the object from the context, because other
> examples think applies to newer releases.
> Any clue about what can I try?, It´s possible that in osgi (equinox) really
> is not getting the separator ? @CsvRecord(separator = ",")
>
> thanks,
> Walter
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5733825.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: A little problem with annotation @CsvRecord

Posted by wpeirone <wp...@gmail.com>.
Hi guys,

I´m using camel bindy 2.8.0-fuse-07-16  in equinox
I tried some of the solutions in this post, but without good results.

I´m still getting java.lang.IllegalArgumentException: The separator has not
been defined in the annotation @CsvRecord or not instantiated during
initModel. must be specified

Last try was with getting the object from the context, because other
examples think applies to newer releases.
Any clue about what can I try?, It´s possible that in osgi (equinox) really
is not getting the separator ? @CsvRecord(separator = ",")

thanks,
Walter




--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5733825.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

Posted by jeff <jf...@gmail.com>.
Thanks @Ib it works in a better clean way with your method !




2013/2/26 lb [via Camel] <ml...@n5.nabble.com>

> You may use the following syntax: .unmarshall().bindy(BindyType.Csv,Your
> Class.class)
>
> Bear in mind that the current implementation does scan the package of the
> viventi class thus you should not have any other bindy-annotated class in
> the same root package.
>
>
> On Monday, February 25, 2013, jeff wrote:
>
> > Thanks  @Claus for the help, but it don't works too...
> >
> > I have found a solution which consist to retrieve the bean from the
> context
> > from the routebuilder :
> >
> > spring bean xml :
> > <bean id="cSVLineFormatAED"
> class="com.myapp...package.CSVLineFormatAED">
> >
> >
> > @CsvRecord(separator = ";" , crlf = "UNIX")
> > public class CSVLineFormatAED extends BindyCsvDataFormat {
> >         public CSVLineFormatAED() {
> >                 super("com.myapp....package");
> >         }
> > }
> >
> > public class BindyRoute extends RouteBuilder {
> >
> >         @Override
> >         public void configure() throws Exception {
> >
> >                 // Context Camel
> >                 SpringCamelContext camelCtx = (SpringCamelContext)
> > getContext();
> >
> >                 // Context Spring
> >                 ApplicationContext springCtx =
> > camelCtx.getApplicationContext();
> >
> >                 BindyCsvDataFormat camelDataFormatAED =
> > (BindyCsvDataFormat) springCtx
> >                                 .getBean("cSVLineFormatAED");
> >
> >                 from("file:C:/input/test.csv")
> >                                 .split(body().tokenize("\n"))
> >                                 .unmarshal(camelDataFormatAED)
> >                                 .to("mock:test").end();
> > ...
> > }
> >
> > Hope it will be helpfull for other developper !
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728119.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728196.html
>  To unsubscribe from A little problem with annotation @CsvRecord, click
> here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5728109&code=amZsZWJlc2NvbnRAZ21haWwuY29tfDU3MjgxMDl8LTE2MjgyOTI4OTg=>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728205.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

Posted by lb <lb...@gmail.com>.
You may use the following syntax: .unmarshall().bindy(BindyType.Csv,Your
Class.class)

Bear in mind that the current implementation does scan the package of the
viventi class thus you should not have any other bindy-annotated class in
the same root package.


On Monday, February 25, 2013, jeff wrote:

> Thanks  @Claus for the help, but it don't works too...
>
> I have found a solution which consist to retrieve the bean from the context
> from the routebuilder :
>
> spring bean xml :
> <bean id="cSVLineFormatAED" class="com.myapp...package.CSVLineFormatAED">
>
>
> @CsvRecord(separator = ";" , crlf = "UNIX")
> public class CSVLineFormatAED extends BindyCsvDataFormat {
>         public CSVLineFormatAED() {
>                 super("com.myapp....package");
>         }
> }
>
> public class BindyRoute extends RouteBuilder {
>
>         @Override
>         public void configure() throws Exception {
>
>                 // Context Camel
>                 SpringCamelContext camelCtx = (SpringCamelContext)
> getContext();
>
>                 // Context Spring
>                 ApplicationContext springCtx =
> camelCtx.getApplicationContext();
>
>                 BindyCsvDataFormat camelDataFormatAED =
> (BindyCsvDataFormat) springCtx
>                                 .getBean("cSVLineFormatAED");
>
>                 from("file:C:/input/test.csv")
>                                 .split(body().tokenize("\n"))
>                                 .unmarshal(camelDataFormatAED)
>                                 .to("mock:test").end();
> ...
> }
>
> Hope it will be helpfull for other developper !
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728119.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: A little problem with annotation @CsvRecord

Posted by jeff <jf...@gmail.com>.
Thanks  @Claus for the help, but it don't works too...

I have found a solution which consist to retrieve the bean from the context
from the routebuilder :

spring bean xml : 
<bean id="cSVLineFormatAED" class="com.myapp...package.CSVLineFormatAED">


@CsvRecord(separator = ";" , crlf = "UNIX")
public class CSVLineFormatAED extends BindyCsvDataFormat {
	public CSVLineFormatAED() {
		super("com.myapp....package");
	}
}

public class BindyRoute extends RouteBuilder {

	@Override
	public void configure() throws Exception {

		// Context Camel
		SpringCamelContext camelCtx = (SpringCamelContext) getContext();

		// Context Spring
		ApplicationContext springCtx = camelCtx.getApplicationContext();

		BindyCsvDataFormat camelDataFormatAED = (BindyCsvDataFormat) springCtx
				.getBean("cSVLineFormatAED");

		from("file:C:/input/test.csv")
				.split(body().tokenize("\n"))
				.unmarshal(camelDataFormatAED)
				.to("mock:test").end();
...
}

Hope it will be helpfull for other developper ! 





--
View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109p5728119.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: A little problem with annotation @CsvRecord

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

I think BindyCsvDataFormat you should specify the package name and not
the FQN class name.


On Mon, Feb 25, 2013 at 5:32 PM, jeff <jf...@gmail.com> wrote:
> Hey !
>
> I am a newbie with this framework. I am designing a little
> MAVEN/SPRING/CAMEL P.O.C.
>
> ( I hope I don't spam, I have already post by mail, put I am not really used
> to nabble :) )
> By the way, I don't understand why spring tell me :
>
> The separator has not been defined in the annotation @CsvRecord or not
> instantiated during initModel. must be specified
>
> I am using spring to initiate the prog :
>
>         <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>                 <package>com.mycomp.mediation.simpleExemple</package>
>         </camelContext>
>
> My main class just do :
>
> new ClassPathXmlApplicationContext("META-INF/spring/SpringBeans.xml");
>
> I have a :
>
>  @CsvRecord(separator = ";" , crlf = "UNIX")
> public class CSVLineFormatAED {
>         @DataField(pos = 1)
>         private String name  = "";
> ...
> }
>
> And a bindy route :
>
> public class BindyRoute extends RouteBuilder {
>         @Override
>         public void configure() throws Exception {
>
>                 BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat(
>                                 "com.mycomp.mediation.simpleExemple.CSVLineFormatAED");
>
>
>                 from("file:C:/input/test.csv")
>                                 .split(body().tokenize("\n"))
>                                 .unmarshal(camelDataFormat)
>                                 .bean(InportSimple.class)
>                 .to("mock:test")
>                                 .end();
>         }
> }
>
> Is anyone has a solution ?
>
> Thanks !
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/A-little-problem-with-annotation-CsvRecord-tp5728109.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen