You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vkarkhanis <vk...@gmail.com> on 2013/08/07 13:51:50 UTC

Using camel route for parsing a csv file

Hello,
We have a simple scenario of reading a CSV file and persisting the records
into database. We have following route configured for the same:

    
<routeContext id="persistIRDCF1"
xmlns="http://camel.apache.org/schema/spring">
       <route id="IRD_CF1_LN_FILE_BATCH">
            <from uri="file://C://Temp//test.csv"/>
            <split streaming="true" parallelProcessing="true">
                                                    <tokenize token="\n"
group="2"/>
                                                    <unmarshal>
                                                          <csv/>
                                                     </unmarshal>
                                                  </split>
                                                  <to uri= "sql:INSERT INTO
mytable (name, height, comments) VALUES (#, #,
#)?dataSourceRef=tsyoneDatasource"/>
        </route>
    </routeContext>



We get following error while executing:


Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/csv/writer/CSVConfig
                at java.lang.Class.getDeclaredMethods0(Native Method)
                at
java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
                at java.lang.Class.getDeclaredMethod(Class.java:1935)
                at
org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.resolveMember(LocalVariableTableParameterNameDiscoverer.java:236)
                at
org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.visitEnd(LocalVariableTableParameterNameDiscoverer.java:219)
                at org.springframework.asm.ClassReader.accept(Unknown
Source)
                at org.springframework.asm.ClassReader.accept(Unknown
Source)


>From what we read, we should be including camel-csv.jar file in classpath to
get this working. We could check that the camel-csv jar is correctly added
to the classpath. We are using camel 2.11.0 version.

Can you please advise if we are missing something here.

Thank you,
Regards

vkarkhanis




--
View this message in context: http://camel.465427.n5.nabble.com/Using-camel-route-for-parsing-a-csv-file-tp5736910.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using camel route for parsing a csv file

Posted by Hilderich <hi...@yahoo.de>.
sub project camel-csv has the following dependency in its POM:

*    <dependency>
      <groupId>org.apache.servicemix.bundles</groupId>
      <artifactId>org.apache.servicemix.bundles.commons-csv</artifactId>
      <version>${commons-csv}</version>
    </dependency>*

There you can find there the class CSVConfig.






--
View this message in context: http://camel.465427.n5.nabble.com/Using-camel-route-for-parsing-a-csv-file-tp5736910p5736928.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Using camel route for parsing a csv file

Posted by Christian Müller <ch...@gmail.com>.
camel-csv cmueller$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building Camel :: CSV 2.11.0
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.6:tree (default-cli) @ camel-csv ---
[INFO] org.apache.camel:camel-csv:bundle:2.11.0
[INFO] +- org.apache.camel:camel-core:jar:2.11.0:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.6.6:compile (version managed from
1.6.6)
[INFO] +-
org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-csv:jar:1.0-r706899_5:compile
[INFO] +- org.apache.camel:camel-test-spring:jar:2.11.0:test
[INFO] |  +- org.apache.camel:camel-test:jar:2.11.0:test (version managed
from 2.11.0)
[INFO] |  +- org.apache.camel:camel-spring:jar:2.11.0:test (version managed
from 2.11.0)
[INFO] |  |  +- org.springframework:spring-context:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] |  |  |  +- org.springframework:spring-beans:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] |  |  |  +- org.springframework:spring-core:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] |  |  |  |  \- commons-logging:commons-logging:jar:1.1.2:test
(version managed from 1.1.1)
[INFO] |  |  |  +-
org.springframework:spring-expression:jar:3.1.4.RELEASE:test (version
managed from 3.1.4.RELEASE)
[INFO] |  |  |  \- org.springframework:spring-asm:jar:3.1.4.RELEASE:test
[INFO] |  |  +- org.springframework:spring-aop:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:test
[INFO] |  |  \- org.springframework:spring-tx:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] |  \- org.springframework:spring-test:jar:3.1.4.RELEASE:test
(version managed from 3.1.4.RELEASE)
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.7.5:test
[INFO] |  \- log4j:log4j:jar:1.2.17:test (version managed from 1.2.17)
[INFO] \- junit:junit:jar:4.11:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test

Best,
Christian

-----------------

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Wed, Aug 7, 2013 at 1:51 PM, vkarkhanis <vk...@gmail.com> wrote:

> Hello,
> We have a simple scenario of reading a CSV file and persisting the records
> into database. We have following route configured for the same:
>
>
> <routeContext id="persistIRDCF1"
> xmlns="http://camel.apache.org/schema/spring">
>        <route id="IRD_CF1_LN_FILE_BATCH">
>             <from uri="file://C://Temp//test.csv"/>
>             <split streaming="true" parallelProcessing="true">
>                                                     <tokenize token="\n"
> group="2"/>
>                                                     <unmarshal>
>                                                           <csv/>
>                                                      </unmarshal>
>                                                   </split>
>                                                   <to uri= "sql:INSERT INTO
> mytable (name, height, comments) VALUES (#, #,
> #)?dataSourceRef=tsyoneDatasource"/>
>         </route>
>     </routeContext>
>
>
>
> We get following error while executing:
>
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/csv/writer/CSVConfig
>                 at java.lang.Class.getDeclaredMethods0(Native Method)
>                 at
> java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
>                 at java.lang.Class.getDeclaredMethod(Class.java:1935)
>                 at
>
> org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.resolveMember(LocalVariableTableParameterNameDiscoverer.java:236)
>                 at
>
> org.springframework.core.LocalVariableTableParameterNameDiscoverer$LocalVariableTableVisitor.visitEnd(LocalVariableTableParameterNameDiscoverer.java:219)
>                 at org.springframework.asm.ClassReader.accept(Unknown
> Source)
>                 at org.springframework.asm.ClassReader.accept(Unknown
> Source)
>
>
> From what we read, we should be including camel-csv.jar file in classpath
> to
> get this working. We could check that the camel-csv jar is correctly added
> to the classpath. We are using camel 2.11.0 version.
>
> Can you please advise if we are missing something here.
>
> Thank you,
> Regards
>
> vkarkhanis
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Using-camel-route-for-parsing-a-csv-file-tp5736910.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Using camel route for parsing a csv file

Posted by jduncan <jd...@iqnavigator.com>.
It looks like you may also need to add the apache commons-csv jar to your
class path.  This is one of the dependencies of the camel-csv jar:
org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-csv

Jared



--
View this message in context: http://camel.465427.n5.nabble.com/Using-camel-route-for-parsing-a-csv-file-tp5736910p5736925.html
Sent from the Camel - Users mailing list archive at Nabble.com.