Вопрос

I am trying to use Oracle jdbc 6 driver in Apache Karaf buy I am facing some difficulties. Particularly, I am trying to make use of the driver to access my database through the Camel SQL Component.

My blueprint file looks like this:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
        <property name="dataSourceName" value="XXXXX" />
        <property name="TNSEntryName" value="XXXXX" />
        <property name="DriverType" value="XXXXX" />
        <property name="user" value="XXXXX" />
        <property name="password" value="XXXXX" />
    </bean>

    <!-- configure the Camel SQL component to use the JDBC data source -->
    <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
        <property name="location" value="file:${karaf.home}/etc/sqlStatements.properties" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route id="metis123">
            <from uri="timer:foo?period=5000" />
            <to uri="sql:{{sql.check_rwos_update}}" id="sqlCheckRwosUpdate" />
            <to uri="log:com.hveiga?showAll=true" />
        </route>
    </camelContext> 
</blueprint>

When I am placing my file into the deploy directory in Karaf I am getting the following exception:

org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to instantiate components
...
Caused by: java.lang.NoClassDefFoundError: javax/sql/DataSource
...
Caused by: java.lang.ClassNotFoundException: javax.sql.DataSource not found by oracle.ojdbc6 [131]

So it seems it is a problem with the oracle driver not being able to find some class. I have osgified the oracle jar using the apache-felix maven plugin but maybe I am doing something wrong and the MANIFEST.MF file is missing something.

Any idea what I could be missing?

Это было полезно?

Решение 2

I have solved my issue by adding to the MANIFEST.MF the following line:

Import-Package: javax.sql, javax.naming, javax.management, org.ietf.jgss

Thanks for all the help!

Другие советы

You might be interested in my karaf db tutorial.

Simply dropping the db driver probably does not work. I describe there to use the wrap: protocol of pax url. This way the drivers are bundled with bnd and default settings on the fly. So this might already give you a working system. For production use it is better though to bundle the drivers using a maven project like bgossit described. You will find a lot of examples for this at servicemix bundles.

I had to do similar wrapping of an Oracle driver into a bundle using Maven. This is what I had that may help:

Oracle bundle:

Export-Package: oracle.jdbc, oracle.jdbc.driver
Import-Package: !javax.*, !oracle.*

Other bundles that refer to it just had Import-Package: * and Maven filled in the rest.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top