You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Reynald <re...@weiner.com.br> on 2012/07/03 00:59:36 UTC

Camel 2.10.0 and Bindy/CSV

Hi all,

I'm starting to use Camel and I'm trying to use Bindy to read a CSV File.
I'm getting the error:

java.lang.IllegalArgumentException: The separator has not been defined in
the annotation @CsvRecord or not instantiated during initModel. must be
specified
	at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:290)
	at
org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:124)
	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:57)

Here is a very simple test:

            	from("direct:start").marshal().bindy(BindyType.Csv,
"services.billing").to("direct:middle");
            	from("direct:middle").unmarshal(new
BindyCsvDataFormat("services.billing.MyBillingItem")).to("direct:test");

And to test, something like this:

		MyBillingItem bill = new MyBillingItem();
		CamelContext ctx = CamelPlugin.getCamelContext();
		bill.id= 1;
		bill.number = "1234;
		ctx.createProducerTemplate().sendBody("direct:start", bill);

On MyBillingItem.class, I have set the annotations:

...
@CsvRecord(separator = ",", quote = "\"", skipFirstLine = true)
public class MyBillingItem {
...

If I'm doing something wrong, please advice.

Thanks

PS. I need to use 2.10.0 because of some features.


--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Christian Müller <ch...@gmail.com>.
Ok, thanks.
One of the committers (may be me) will have a look on it.

Best,
Christian

On Thu, Jul 5, 2012 at 9:05 PM, Reynald <re...@weiner.com.br> wrote:

> Hi Chris,
>
> Sorry for the delay.
>
> I just created:
>
> https://issues.apache.org/jira/browse/CAMEL-5423
>
> If you need anything else, let me know.
>
> tks.
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715565.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel 2.10.0 and Bindy/CSV

Posted by Reynald <re...@weiner.com.br>.
Hi Chris,

Sorry for the delay.

I just created:

https://issues.apache.org/jira/browse/CAMEL-5423

If you need anything else, let me know.

tks.

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715565.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Charles Moulliard <cm...@gmail.com>.
There is no bug. See my last response. Nevertheless, I will add unit test
(CAMEL-5421)

-----
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715502.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Christian Müller <ch...@gmail.com>.
Could you please raise a JIRA for the case you got a NPE!?

Best,
Christian

Sent from a mobile device
Am 03.07.2012 17:33 schrieb "Reynald" <re...@weiner.com.br>:

> I could make it work with this:
>
> from("direct:start").unmarshal().bindy(BindyType.Csv,
> "services.billing").to("direct:test");
>
> Somehow all the other combinations generated nullpointerexceptions.
>
> Thanks!!!
>
> PS. Camel is fantastic! It spare us days of programming and testing only
> with this feature and this is just the beginning :).
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715410.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel 2.10.0 and Bindy/CSV

Posted by Charles Moulliard <cm...@gmail.com>.
Reynald,

When you would like to use directly the Class instead of providing the
package to be used 
the syntax is  --> bindy(BindyType.Csv, services.billing.class). So the
quotes should be removed and class added at the end. 

Regards,




-----
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715500.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Reynald <re...@weiner.com.br>.
I could make it work with this:

from("direct:start").unmarshal().bindy(BindyType.Csv,
"services.billing").to("direct:test");

Somehow all the other combinations generated nullpointerexceptions. 

Thanks!!!

PS. Camel is fantastic! It spare us days of programming and testing only
with this feature and this is just the beginning :).

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715410.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Claus Ibsen <cl...@gmail.com>.
In Camel 2.10 you can provide the class itself which makes it a tad easier

 from("direct:middle")
 .unmarshal(new BindyCsvDataFormat(MyBillingItem.class))
 .to("direct:test");

And there is bindy in the DSL, so you can do

 from("direct:middle")
   .unmarshal().bindy(BindyType.Csv, MyBillingItem.class)
 .to("direct:test");

On Tue, Jul 3, 2012 at 10:04 AM, Charles Moulliard <cm...@gmail.com> wrote:
> Hi Reynald,
>
> Your syntax is not correct as you must provide the package name (that bindy
> will scan) and not the name of the class
>
> from("direct:middle").unmarshal(new
> BindyCsvDataFormat("services.billing.MyBillingItem")).to("direct:test");
>
> should be
>
> from("direct:middle").unmarshal(new
> BindyCsvDataFormat("services.billing")).to("direct:test");
>
> Regards,
>
>
> -----
> Apache Committer / Sr. Pr. Consultant at FuseSource.com
> Email: [hidden email]
> Twitter : @cmoulliard, @fusenews
> Blog : http://cmoulliard.blogspot.com
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715395.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel 2.10.0 and Bindy/CSV

Posted by Charles Moulliard <cm...@gmail.com>.
Hi Reynald,

Your syntax is not correct as you must provide the package name (that bindy
will scan) and not the name of the class

from("direct:middle").unmarshal(new
BindyCsvDataFormat("services.billing.MyBillingItem")).to("direct:test"); 

should be

from("direct:middle").unmarshal(new
BindyCsvDataFormat("services.billing")).to("direct:test"); 

Regards,


-----
Apache Committer / Sr. Pr. Consultant at FuseSource.com
Email: [hidden email]
Twitter : @cmoulliard, @fusenews
Blog : http://cmoulliard.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715395.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel 2.10.0 and Bindy/CSV

Posted by Reynald <re...@weiner.com.br>.
I tested this code on 2.9.2 and it does not work either. 

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-2-10-0-and-Bindy-CSV-tp5715387p5715389.html
Sent from the Camel - Users mailing list archive at Nabble.com.