You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by xlogger <xl...@gmail.com> on 2015/09/23 04:50:06 UTC

Karaf 4.0.1 -- create Pooled Oracle datasource

I was trying to follow the instruction from this blog to create a
datasource-oracle.xml file and put into deploy folder
http://www.sachinhandiekar.com/2013/08/oracle-datasource-in-fuse-esb-apache.html 

when I use "bundle:list" I can see the datasource-oracle.xml bundle
installed

136 | Active  |  80 | 0              | wrap_mvn_com.oracle_ojdbc6_11.2.0
140 | Active  |  80 | 0.0.0          | datasource-oracle.xml

Then I tried to "feature:install jdbc" and then "jdbc:ds-list", there is no
datasource found in the list.

Is there any config I've missed to make the datasource recognizable by the
jdbc feature?

Also, I tried to check the karaf jdbc documentation but seems the commands
are different from what I have... e.g. I have jdbc:ds-list and
jdbc:ds-create commands, but the documentation is showing jdbc:datasources
and jdbc:create, the options for those commands are different from what I
have too... wondering if I have installed a wrong jdbc feature...

http://karaf.apache.org/manual/latest/users-guide/jdbc.html


karaf@root()> feature:list |grep jdbc
jdbc                                    | 4.0.1            | x        |
Started     | enterprise-4.0.1                | JDBC service and commands



karaf@root()> jdbc --help 

SUBSHELL
        jdbc

COMMANDS
    jdbc:ds-create    Create a JDBC datasource config for pax-jdbc-config
from a DataSourceFactory
    jdbc:ds-delete    Delete a JDBC datasource
    jdbc:ds-factories List the JDBC DataSourceFactories
    jdbc:ds-info      Display details about a JDBC datasource
    jdbc:ds-list      List the JDBC datasources
    jdbc:execute      Execute a SQL command on a given JDBC datasource
    jdbc:query        Execute a SQL query on a JDBC datasource
    jdbc:tables       List the tables on a given JDBC datasource






--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by Francois Papon <fr...@openobject.fr>.
Hi,

You have to install the jdbc drivers, you can find an example here using
Pax-jdbc :

https://github.com/jbonofre/karaf/tree/DEV_GUIDE/examples/karaf-jdbc-example

regards,

François Papon
fpapon@apache.org

Le 20/07/2018 à 14:57, manisv a écrit :
> Hi,
> I've followed all the necessary steps to create a datasource in Karaf. Once
> I deployed the org.ops4j.datasource-test.cfg into etc folder via feature
> install, I could see the below log entry in Karaf.
> I don't see any datasource listed when I checked using jdbc:ds-list command.
>
> Waiting for service dependency:
> (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=oracle.jdbc.driver.OracleDriver))
>
> Thanks
> Mani
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by manisv <s....@gmail.com>.
Hi,
I've followed all the necessary steps to create a datasource in Karaf. Once
I deployed the org.ops4j.datasource-test.cfg into etc folder via feature
install, I could see the below log entry in Karaf.
I don't see any datasource listed when I checked using jdbc:ds-list command.

Waiting for service dependency:
(&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=oracle.jdbc.driver.OracleDriver))

Thanks
Mani



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html

Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by xlogger <xl...@gmail.com>.
Sorry but 1 follow up question:

Previously if blueprint XML is used for Datasource definition, we could
externalize the property values using something like:

<ext:property-placeholder placeholder-prefix="${" placeholder-suffix="}">  
            <ext:location>file:conf/other.properties"</ext:location>  
        </ext:property-placeholder>  

Is it possible to externalize property in org.ops4j.datasource-<ds_name>.cfg
file?




--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724p4042756.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by Christian Schneider <ch...@die-schneider.net>.
Sounds good for the most part.

I would only change to

osgi.jdbc.driver.name=oracle-pool-xa

As you probably want a DataSource that can take part in XA Transactions.
Just do not forget to install the transaction feature.

Christian

On 23.09.2015 15:17, xlogger wrote:
> Many Thanks for your help!
>
> I was able to create the Oracle DataSource and reference through osgi
> service in Spring XML
>
> Record my steps here just in case it might be helpful for others:
>
> 1) Go to the folder where ojdbc6.jar is located then enter the following in
> command prompt:
> mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle
> -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
>
> 2) Go to karaf shell and enter:
> install -s wrap:mvn:com.oracle/ojdbc6/11.2.0
> feature:repo-add pax-jdbc 0.7.0
> feature:install jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
> transaction
>
> 3) Check that 3 DataSourceFactories (OracleDriver, OracleDriver-pool and
> OracleDriver-pool-xa) exists:
> service:list DataSourceFactory
>
> 4) create "org.ops4j.datasource-<ds_name>.cfg" with the following contents
> and store in karaf "etc" folder
>
> osgi.jdbc.driver.name=oracle-pool
> databaseName=<ds_name>
> user=<username>
> password=<password>
> dataSourceName=<osgi_jndi_servicename_to-be_in_spring>
> url=jdbc:oracle:thin:@<oracle_host>:<oracle_port>/<sid>
>
> 5) Check the datasource created:
> service:list DataSource
>
> 6) In Spring XML (Note the osgi namespece and )
>
> In Camel Application's Spring XML (note the hightlighted)
> <?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"
>         xmlns:osgi="http://www.springframework.org/schema/osgi"
>         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
>            http://www.springframework.org/schema/osgi
> http://www.springframework.org/schema/osgi/spring-osgi.xsd
>   ">
>
> ...
>     <camelContext xmlns="http://camel.apache.org/schema/spring">
> ...
>      </camelContext >
>     
>      <osgi:reference id=&quot;db001&quot;
> interface=&quot;javax.sql.DataSource&quot;
> filter=&quot;(osgi.jndi.service.name=&lt;osgi_jndi_servicename_to-be_in_spring>)"
> />
> </beans>
>
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724p4042733.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by xlogger <xl...@gmail.com>.
Many Thanks for your help!

I was able to create the Oracle DataSource and reference through osgi
service in Spring XML 

Record my steps here just in case it might be helpful for others:

1) Go to the folder where ojdbc6.jar is located then enter the following in
command prompt:
mvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle
-DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

2) Go to karaf shell and enter:
install -s wrap:mvn:com.oracle/ojdbc6/11.2.0
feature:repo-add pax-jdbc 0.7.0
feature:install jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
transaction

3) Check that 3 DataSourceFactories (OracleDriver, OracleDriver-pool and
OracleDriver-pool-xa) exists:
service:list DataSourceFactory

4) create "org.ops4j.datasource-<ds_name>.cfg" with the following contents
and store in karaf "etc" folder

osgi.jdbc.driver.name=oracle-pool
databaseName=<ds_name>
user=<username>
password=<password>
dataSourceName=<osgi_jndi_servicename_to-be_in_spring>
url=jdbc:oracle:thin:@<oracle_host>:<oracle_port>/<sid>

5) Check the datasource created:
service:list DataSource

6) In Spring XML (Note the osgi namespece and )

In Camel Application's Spring XML (note the hightlighted)
<?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"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       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
          http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
 ">

...
   <camelContext xmlns="http://camel.apache.org/schema/spring">
...
    </camelContext >
   
    <osgi:reference id=&quot;db001&quot; 
interface=&quot;javax.sql.DataSource&quot;
filter=&quot;(osgi.jndi.service.name=&lt;osgi_jndi_servicename_to-be_in_spring>)"  
/>
</beans>







--
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724p4042733.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
By the way, I will update the Karaf 4 user guide to reflect the change 
(I forgot).

Regards
JB

On 09/23/2015 10:01 AM, Christian Schneider wrote:
> The model to create datasources has changed in karaf 4.
>
> We now use pax-jdbc to setup the DataSource.
> Unfortunately I found a problem in the jdbc commands when testing the
> below steps.
> The jdbc:ds-list command did not work for me. I will look into it.
>
> Try the steps below. It should be possible to create a DataSource from
> config even without the commands.
>
> 1. Install your wrapped oracle driver
>
> 2. Install pax-jdbc and the karaf jdbc commands
>
> feature:repo-add pax-jdbc 0.7.0
> feature:install jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
>
> 3. Check that a DataSourceFactory exists
>
> service:list DataSourceFactory
> This should show you Oracle DSF.
>
> 3. Install the data source config
>
> Normally you should be able to do this using the jdbc commands.
> As they just create a config in etc you can also follow the docs below.
>
> https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config
> https://ops4j1.jira.com/wiki/display/PAXJDBC/Pooling+and+XA+support+for+DataSourceFactory
>
>
>
>
>
>
>
> On 23.09.2015 04:50, xlogger wrote:
>> I was trying to follow the instruction from this blog to create a
>> datasource-oracle.xml file and put into deploy folder
>> http://www.sachinhandiekar.com/2013/08/oracle-datasource-in-fuse-esb-apache.html
>>
>>
>> when I use "bundle:list" I can see the datasource-oracle.xml bundle
>> installed
>>
>> 136 | Active  |  80 | 0              | wrap_mvn_com.oracle_ojdbc6_11.2.0
>> 140 | Active  |  80 | 0.0.0          | datasource-oracle.xml
>>
>> Then I tried to "feature:install jdbc" and then "jdbc:ds-list", there
>> is no
>> datasource found in the list.
>>
>> Is there any config I've missed to make the datasource recognizable by
>> the
>> jdbc feature?
>>
>> Also, I tried to check the karaf jdbc documentation but seems the
>> commands
>> are different from what I have... e.g. I have jdbc:ds-list and
>> jdbc:ds-create commands, but the documentation is showing
>> jdbc:datasources
>> and jdbc:create, the options for those commands are different from what I
>> have too... wondering if I have installed a wrong jdbc feature...
>>
>> http://karaf.apache.org/manual/latest/users-guide/jdbc.html
>>
>>
>> karaf@root()> feature:list |grep jdbc
>> jdbc                                    | 4.0.1            | x        |
>> Started     | enterprise-4.0.1                | JDBC service and commands
>>
>>
>>
>> karaf@root()> jdbc --help
>>
>> SUBSHELL
>>          jdbc
>>
>> COMMANDS
>>      jdbc:ds-create    Create a JDBC datasource config for
>> pax-jdbc-config
>> from a DataSourceFactory
>>      jdbc:ds-delete    Delete a JDBC datasource
>>      jdbc:ds-factories List the JDBC DataSourceFactories
>>      jdbc:ds-info      Display details about a JDBC datasource
>>      jdbc:ds-list      List the JDBC datasources
>>      jdbc:execute      Execute a SQL command on a given JDBC datasource
>>      jdbc:query        Execute a SQL query on a JDBC datasource
>>      jdbc:tables       List the tables on a given JDBC datasource
>>
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724.html
>>
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by Christian Schneider <ch...@die-schneider.net>.
Oops .. my bad. When I used jdbc:ds-factories it worked.
You should also do "feature:install transaction" to get a xa ready 
DataSourceFactory.

Christian


On 23.09.2015 10:01, Christian Schneider wrote:
> The model to create datasources has changed in karaf 4.
>
> We now use pax-jdbc to setup the DataSource.
> Unfortunately I found a problem in the jdbc commands when testing the 
> below steps.
> The jdbc:ds-list command did not work for me. I will look into it.
>
> Try the steps below. It should be possible to create a DataSource from 
> config even without the commands.
>
> 1. Install your wrapped oracle driver
>
> 2. Install pax-jdbc and the karaf jdbc commands
>
> feature:repo-add pax-jdbc 0.7.0
> feature:install jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle
>
> 3. Check that a DataSourceFactory exists
>
> service:list DataSourceFactory
> This should show you Oracle DSF.
>
> 3. Install the data source config
>
> Normally you should be able to do this using the jdbc commands.
> As they just create a config in etc you can also follow the docs below.
>
> https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config 
>
> https://ops4j1.jira.com/wiki/display/PAXJDBC/Pooling+and+XA+support+for+DataSourceFactory 
>
>
>
>
>
>
>
> On 23.09.2015 04:50, xlogger wrote:
>> I was trying to follow the instruction from this blog to create a
>> datasource-oracle.xml file and put into deploy folder
>> http://www.sachinhandiekar.com/2013/08/oracle-datasource-in-fuse-esb-apache.html 
>>
>>
>> when I use "bundle:list" I can see the datasource-oracle.xml bundle
>> installed
>>
>> 136 | Active  |  80 | 0              | wrap_mvn_com.oracle_ojdbc6_11.2.0
>> 140 | Active  |  80 | 0.0.0          | datasource-oracle.xml
>>
>> Then I tried to "feature:install jdbc" and then "jdbc:ds-list", there 
>> is no
>> datasource found in the list.
>>
>> Is there any config I've missed to make the datasource recognizable 
>> by the
>> jdbc feature?
>>
>> Also, I tried to check the karaf jdbc documentation but seems the 
>> commands
>> are different from what I have... e.g. I have jdbc:ds-list and
>> jdbc:ds-create commands, but the documentation is showing 
>> jdbc:datasources
>> and jdbc:create, the options for those commands are different from 
>> what I
>> have too... wondering if I have installed a wrong jdbc feature...
>>
>> http://karaf.apache.org/manual/latest/users-guide/jdbc.html
>>
>>
>> karaf@root()> feature:list |grep jdbc
>> jdbc                                    | 4.0.1            | x        |
>> Started     | enterprise-4.0.1                | JDBC service and 
>> commands
>>
>>
>>
>> karaf@root()> jdbc --help
>>
>> SUBSHELL
>>          jdbc
>>
>> COMMANDS
>>      jdbc:ds-create    Create a JDBC datasource config for 
>> pax-jdbc-config
>> from a DataSourceFactory
>>      jdbc:ds-delete    Delete a JDBC datasource
>>      jdbc:ds-factories List the JDBC DataSourceFactories
>>      jdbc:ds-info      Display details about a JDBC datasource
>>      jdbc:ds-list      List the JDBC datasources
>>      jdbc:execute      Execute a SQL command on a given JDBC datasource
>>      jdbc:query        Execute a SQL query on a JDBC datasource
>>      jdbc:tables       List the tables on a given JDBC datasource
>>
>>
>>
>>
>>
>>
>> -- 
>> View this message in context: 
>> http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724.html
>> Sent from the Karaf - User mailing list archive at Nabble.com.
>
>


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Karaf 4.0.1 -- create Pooled Oracle datasource

Posted by Christian Schneider <ch...@die-schneider.net>.
The model to create datasources has changed in karaf 4.

We now use pax-jdbc to setup the DataSource.
Unfortunately I found a problem in the jdbc commands when testing the 
below steps.
The jdbc:ds-list command did not work for me. I will look into it.

Try the steps below. It should be possible to create a DataSource from 
config even without the commands.

1. Install your wrapped oracle driver

2. Install pax-jdbc and the karaf jdbc commands

feature:repo-add pax-jdbc 0.7.0
feature:install jdbc pax-jdbc-config pax-jdbc-pool-dbcp2 pax-jdbc-oracle

3. Check that a DataSourceFactory exists

service:list DataSourceFactory
This should show you Oracle DSF.

3. Install the data source config

Normally you should be able to do this using the jdbc commands.
As they just create a config in etc you can also follow the docs below.

https://ops4j1.jira.com/wiki/display/PAXJDBC/Create+DataSource+from+config
https://ops4j1.jira.com/wiki/display/PAXJDBC/Pooling+and+XA+support+for+DataSourceFactory






On 23.09.2015 04:50, xlogger wrote:
> I was trying to follow the instruction from this blog to create a
> datasource-oracle.xml file and put into deploy folder
> http://www.sachinhandiekar.com/2013/08/oracle-datasource-in-fuse-esb-apache.html
>
> when I use "bundle:list" I can see the datasource-oracle.xml bundle
> installed
>
> 136 | Active  |  80 | 0              | wrap_mvn_com.oracle_ojdbc6_11.2.0
> 140 | Active  |  80 | 0.0.0          | datasource-oracle.xml
>
> Then I tried to "feature:install jdbc" and then "jdbc:ds-list", there is no
> datasource found in the list.
>
> Is there any config I've missed to make the datasource recognizable by the
> jdbc feature?
>
> Also, I tried to check the karaf jdbc documentation but seems the commands
> are different from what I have... e.g. I have jdbc:ds-list and
> jdbc:ds-create commands, but the documentation is showing jdbc:datasources
> and jdbc:create, the options for those commands are different from what I
> have too... wondering if I have installed a wrong jdbc feature...
>
> http://karaf.apache.org/manual/latest/users-guide/jdbc.html
>
>
> karaf@root()> feature:list |grep jdbc
> jdbc                                    | 4.0.1            | x        |
> Started     | enterprise-4.0.1                | JDBC service and commands
>
>
>
> karaf@root()> jdbc --help
>
> SUBSHELL
>          jdbc
>
> COMMANDS
>      jdbc:ds-create    Create a JDBC datasource config for pax-jdbc-config
> from a DataSourceFactory
>      jdbc:ds-delete    Delete a JDBC datasource
>      jdbc:ds-factories List the JDBC DataSourceFactories
>      jdbc:ds-info      Display details about a JDBC datasource
>      jdbc:ds-list      List the JDBC datasources
>      jdbc:execute      Execute a SQL command on a given JDBC datasource
>      jdbc:query        Execute a SQL query on a JDBC datasource
>      jdbc:tables       List the tables on a given JDBC datasource
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-4-0-1-create-Pooled-Oracle-datasource-tp4042724.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com