You can check if the datasource works by using my db commands for karaf:
https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
You should also check with the service:list command if the blueprint.xml
offers the DataSource service.
Christian
Am 26.04.2012 10:45, schrieb Borut Bolčina:
Hello,
thanks Bengt for your input, I really appreciate you took the time!
My work on this is somehow sporadic, but now I have managed to get the
Camel route running in Karaf
from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
.log("Getting weather from: " + sourceUrl)
.to(sourceUrl)
.split()
.tokenizeXML("metData")
.unmarshal(jaxbDataFormat)
.to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
with the exception of saving the data to the database which fails with:
Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in
the ConnectionDriverName property. Available properties in
configuration are
"org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
at
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
....
My datasource bundle is deployed in OSGi (later the username and
password will be configurable, that is - outside of the bundle)
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="weatherDataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<property name="url"
value="jdbc:mysql://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8
<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
/>
<property name="user" value="myUsername" />
<property name="password" value="myPassword" />
</bean>
<service interface="javax.sql.DataSource" ref="weatherDataSource">
<service-properties>
<entry key="osgi.jndi.service.name <http://osgi.jndi.service.name>"
value="jdbc/mysqlds" />
</service-properties>
</service>
</blueprint>
which is used by my model bundle's persistence.xml
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="weather" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
<http://osgi.jndi.service.name>=jdbc/mysqlds)</jta-data-source>
<class>my.company.weather.entities.WeatherCurrent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
</persistence-unit>
</persistence>
I think the problem is that my model bundle is not seeing the
datasource service. How do I confirm that or how should my model's
MANIFEST look like?
Cheers,
borut
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com