You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "vs.souza" <vs...@gmail.com> on 2012/03/01 21:31:19 UTC
OpenJPA, MySQL, DBCP and Camel Route - Exception
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.
Re: OpenJPA, MySQL, DBCP and Camel Route - Exception
Posted by "vs.souza" <vs...@gmail.com>.
Hello dudes,
solved adding this to my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<includes>com/test/integration/camel/spring/poc/file/**/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
</plugin>
This enhances classes during build process.
Thanks and cheers.
--
View this message in context: http://servicemix.396122.n5.nabble.com/OpenJPA-MySQL-DBCP-and-Camel-Route-Exception-tp5529115p5529623.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: OpenJPA, MySQL, DBCP and Camel Route - Exception
Posted by "vs.souza" <vs...@gmail.com>.
ok guys...
solved the problem with this bean configs:
<?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="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/servicemix-camel-db" />
<property name="username" value="root" />
<property name="password" value="mysql" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="camelPU"/>
<property name="jpaVendorAdapter" ref="jpaAdapter"/>
<property name="dataSource" ref="dataSource" />
</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>
and persistence.xml:
<?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.Log" value="DefaultLevel=WARN, Tool=INFO"/>
</properties>
</persistence-unit>
</persistence>
but now got to a problem relative to entity enhancement:
19:15:14,128 | ERROR | read #11 - Split | DefaultErrorHandler |
90 - org.apache.camel.camel-core - 2.8.3 | Failed delivery for exchangeId:
ID-deathstar-52480-1330640027104-1-30. Exhausted after delivery attempt: 1
caught: org.springframework.dao.InvalidDataAccessApiUsageException: The type
"class com.test.integration.camel.spring.poc.file.CSVEventRecordBean" has
not been enhanced.; nested exception is <openjpa-2.1.1-r422266:1148538 fatal
user error> org.apache.openjpa.persistence.ArgumentException: The type
"class com.test.integration.camel.spring.poc.file.CSVEventRecordBean" has
not been enhanced.
FailedObject:
com.test.integration.camel.spring.poc.file.CSVEventRecordBean@198b372
[java.lang.String]
org.springframework.dao.InvalidDataAccessApiUsageException: The type "class
com.test.integration.camel.spring.poc.file.CSVEventRecordBean" has not been
enhanced.; nested exception is <openjpa-2.1.1-r422266:1148538 fatal user
error> org.apache.openjpa.persistence.ArgumentException: The type "class
com.test.integration.camel.spring.poc.file.CSVEventRecordBean" has not been
enhanced.
FailedObject:
com.test.integration.camel.spring.poc.file.CSVEventRecordBean@198b372
Any ideas?
Cheers.
--
View this message in context: http://servicemix.396122.n5.nabble.com/OpenJPA-MySQL-DBCP-and-Camel-Route-Exception-tp5529115p5529410.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
Re: OpenJPA, MySQL, DBCP and Camel Route - Exception
Posted by Johan Edstrom <je...@savoirtech.com>.
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.
On Mar 1, 2012, at 1:31 PM, vs.souza wrote:
> 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.