0

I have a blueprint file which I am deploying to deploy folder which creates datasource and registers it as a service . In the feature file I am wrapping ojdbc7 and ucp.jar (both versions 12.1.0.2) and deployin . I have another bundle which accesses the datasource and when inserting a record I get the ClassNotFoundException oracle.jdbc.pool.OracleDataSource at runtime. There is not problem deploying all bundles. I see both oracle jars export the proper packages.I am trying to create a connection pool as below in blueprint file

    <bean id="dataSource" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource">
<property name="URL" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.pwd}" />
<property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource" />
<property name="connectionPoolName" value="oracle_pool" />
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="initialPoolSize" value="5" />
  </bean>
behal
  • 1

2 Answers2

0

You are setting the data source class as a string in connectionFactoryClassName. PoolDataSourceFactory seems to load this class using the wrong classloader so that does not work.

A working solution for DataSources in OSGi is pax-jdbc. See also the Oracle driver adapter. In karaf you simply load the features and create a config.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Thanks Christian where can i find an example of using pax-jdbc and aries-pool . I am confused on how to achive the pax jdbc using a feature file – behal Mar 14 '16 at 18:19
  • never mind i figured out how to do it thanks and pax jdbc works great. Just curious is there no way to make the above code work ? This is how Oracle recommends to create a Connection Pool – behal Mar 14 '16 at 18:36
0

Please see the UCP configuration with Spring.

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 
<!-- Initialization for data source --> 
<bean id="dataSource" class="oracle.ucp.jdbc.PoolDataSourceImpl"> 
<property name="connectionFactoryClassName" value="oracle.jdbc.pool.OracleDataSource"/> 
<property name="URL" value="jdbc:oracle:thin:@//host:port/service_name"/> 
<property name="user" value="scott"/> 
<property name="password" value="tiger"/> 
<property name="maxPoolSize" value="10"/> 
<property name="initialPoolSize" value="5"/> 
</bean> 
<!-- Definition for EmpJDBCTemplate bean --> 
<bean id="EmpJDBCTemplate" class="test.EmpJDBCTemplate"> 
<property name="dataSource" ref="dataSource"/> 
</bean> 
</beans>
Nirmala
  • 1,278
  • 1
  • 10
  • 11