Hello my friends,

I'm trying to load data from a csv file and dump into a database but it
looks like a hell of a task. I already atempted to solve the problem in a
lot of different ways but had no success. The exception I get is:

17:21:34,110 | ERROR | read #51 - Split | DefaultErrorHandler              |
90 - org.apache.camel.camel-core - 2.8.3 | Failed delivery for exchangeId:
ID-deathstar-57818-1330631643795-4-29. Exhausted after delivery attempt: 1
caught: org.springframework.transaction.CannotCreateTransactionException:
Could not open JPA EntityManager for transaction; nested exception is
<openjpa-2.1.1-r422266:1148538 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A connection could not be
obtained for driver class "org.apache.commons.dbcp.BasicDataSource" and URL
"jdbc:mysql://localhost:3306/servicemix-camel-db".  You may have specified
an invalid URL.
org.springframework.transaction.CannotCreateTransactionException: Could not
open JPA EntityManager for transaction; nested exception is
<openjpa-2.1.1-r422266:1148538 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A connection could not be
obtained for driver class "org.apache.commons.dbcp.BasicDataSource" and URL
"jdbc:mysql://localhost:3306/servicemix-camel-db".  You may have specified
an invalid URL.
        at
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:382)[217:org.springframework.orm:3.0.6.RELEASE]
        at
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)[93:org.springframework.transaction:3.0.6.RELEASE]

I created a fragment bundle for mysql driver and it is recognized by dbcp as
displayed by osgi:list:

[ 226] [Active     ] [            ] [       ] [   60] Apache ServiceMix ::
Bundles :: commons-dbcp (1.2.2.7)
                                       Fragments: 305
[ 228] [Active     ] [            ] [       ] [   50] camel-jdbc (2.8.3)
[ 229] [Active     ] [            ] [       ] [   60] OpenJPA Aggregate Jar
(2.1.1)
[ 230] [Active     ] [            ] [       ] [   60] Apache Geronimo
JSR-317 JPA 2.0 Spec API (1.1)
[ 305] [Resolved   ] [            ] [       ] [   60] MySQL JDBC DBCP
Fragment (5.1.18)
                                       Hosts: 226

my persistence.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="1.0">
  <persistence-unit name="camelPU" transaction-type="RESOURCE_LOCAL">
   
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
   
<class>com.test.integration.camel.spring.poc.file.CSVEventRecordBean</class>
    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties>
        <property name="openjpa.ConnectionDriverName"
value="org.apache.commons.dbcp.BasicDataSource"/>
        <property name="openjpa.ConnectionProperties"
value="DriverClassName=com.mysql.jdbc.Driver"/>
        <property name="openjpa.ConnectionURL"
value="jdbc:mysql://localhost:3306/servicemix-camel-db"/>
        <property name="openjpa.ConnectionUserName" value="root"/>
        <property name="openjpa.ConnectionPassword" value="mysql"/>
        <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
    </properties>
  </persistence-unit>
</persistence>

and this is my route:


<?xml version="1.0" encoding="UTF-8"?>




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

  <bean  id="bindyDataFormat"
class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat">
    <constructor-arg value="com.test.integration.camel.spring.poc.file"/>
  </bean>
  
  <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
  </bean>
  
  <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="camelPU"/>
    <property name="jpaVendorAdapter" ref="jpaAdapter"/>
  </bean>
  
  <bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
    <property name="databasePlatform"
value="org.apache.openjpa.jdbc.sql.MySQLDictionary" />
    <property name="database" value="MYSQL"/>
  </bean>
  
  <bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager">
      <bean class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
      </bean>
    </property>
  </bean>
  
  <camel:camelContext xmlns="http://camel.apache.org/schema/spring";>
    <camel:package>com.test.integration.camel.spring.poc</camel:package>
    <camel:route>
      <camel:from
uri="file:/home/jedimaster/Java-Env/Sandbox/DB/From?delete=true"/>
          <camel:log message="Started unmarshalling file ${file:name}..."/>
      <camel:split streaming="true" parallelProcessing="true">
        <camel:tokenize token="\n"/>
        <camel:unmarshal ref="bindyDataFormat"/>
        <camel:split>
         
<camel:simple>in.body[0]?[com.test.integration.camel.spring.poc.file.CSVEventRecordBean]</camel:simple>
          <camel:to
uri="jpa:com.test.integration.camel.spring.poc.file.CSVEventRecordBean"/>
        </camel:split>
      </camel:split>
      <camel:log message="Finished unmarshalling file ${file:name}..."/>
    </camel:route>
  </camel:camelContext>

</beans>

Do you have any tips to bring me some light to the end of the tunnel?

Thanks for the help and cheers, my friends.



--
View this message in context: 
http://servicemix.396122.n5.nabble.com/OpenJPA-MySQL-DBCP-and-Camel-Route-Exception-tp5529115p5529115.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to