I added all of your properties with the exception of "validationQuery" and 
"transactionManager. 



We dont' use a validation query, so I didn't include it.  Is that required for 
OSGI/Oracle? 



Could you please include your transaction manager bean?  Is that required? 



v/r, 



Mike Van 




----- Original Message ----- 
From: "iocanel [via Karaf]" <[email protected]> 
To: "Mike Van" <[email protected]> 
Sent: Thursday, October 28, 2010 4:36:43 AM 
Subject: Re: Karaf Spring Hibernate DBCP issue 

Hi Mike, 

I have seen a similar (if not the same error). When you use dbcpb & spring you 
must keep in mind that the properties will be set on the JDBC driver instance 
using reflection. In some cases this can be source of problems. 

Anyway here is something that works for me (using managed datasource): 

<bean id="myDataSource" 
class="org.apache.commons.dbcp.managed.BasicManagedDataSource" 
destroy-method="close"> 
                <property name="driverClassName" value="${db.driver.class}"/> 
                <property name="url" value="${db.url}"/> 
                <property name="username" value="${db.user}"/> 
                <property name="password" value="${db.password}"/> 
                <property name="maxIdle" value="10"/> 
                <property name="maxActive" value="100"/> 
                <property name="maxWait" value="10000"/> 
                <property name="validationQuery" value="select 1 from dual"/> 
                <property name="testOnBorrow" value="false"/> 
                <property name="testWhileIdle" value="true"/> 
                <property name="timeBetweenEvictionRunsMillis" 
value="1200000"/> 
                <property name="minEvictableIdleTimeMillis" value="1800000"/> 
                <property name="numTestsPerEvictionRun" value="5"/> 
                <property name="defaultAutoCommit" value="false"/> 
                <property name="transactionManager"  ref="transactionManager"/> 
        </bean> 
  
I have tried that using version 10.2.0.2 oracle driver from springsource ebr 
and dbcp version 1.4. 
db.url = jdbc:oracle:thin:@${IP}:${PORT}:${DB} 
db.driver.class = oracle.jdbc.driver.OracleDriver 

I have successfully deployed that inside karaf. 



On Thu, Oct 28, 2010 at 5:46 AM, Mike Van < [hidden email] > wrote: 





All, 



I believe this is an issue caused by a property not being set when initializing 
Oracle. To verify this, I posted the following to the 
http://forums.oracle.com/forums/thread.jspa?threadID=1981858&tstart=0  . I've 
seen this bug on a number of help-sites with no clear answer, so lets hope I 
can nudge them and tell me what I'm missing!!  And, apologies for the truncated 
message. 





-------------  Posted to Oracle Forums ---------------- 
When connecting to Oracle 10G from Java using Hibernate through Karaf, I 
recieve the following exception string: 


Caused by: org.springframework.beans.factor.BeanCreationException: Error 
creating bean with name 'myAppSessionFactory' defined in class path 

resource [myApp/util/dataSource/applicationContext.xml]: Invocation of init 
method failed; nexted exception is 

java.lang.ArrayIndexOutOfBoundsException: -1 
more exceptions 
.. 58 more 
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 
at 
oracle.jdbc.driver.T4CTTIoauthenticate.setSessionFields(T4CTTI0authenticate.java:972)
 
at oracle.jdbc.driver.T4CTTIoauthenticate.<init>(T4CTTI0authenticate.java:185) 
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:352) 
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:441) 
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) 
at 
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) 
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) 
at 
org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
 
at 
org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
 
at 
org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1240)
 
at 
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1240)
 
at 
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:882) 
at 
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getconnection(LocalDataSourceConnectionProvider.java:81)
 

When tracing through the application with a debugger, I see that the exception 
is a nullPointerException thrown right after 
T4CTTIoauthenticate.setSessionFields sets the class value "aclValue" to an 
empty array "[]". 

When T4CTTIoauthenticate.setSessionFields is called, the following properties 
are passed in to it: 
{user=myAppUser, password=myAppPwd, protocol=thin} 

The following is the spring code used to set-up the connection: 

<bean id="myAppPoolDataSource" class="org.apache.commons.dbcp.BasicDataSource" 
destroy-method="close 
p:driverclassName="${myApp.db.driver}" 
p:url="${myApp.url}" 
p:username="${myApp.userName}" 
p:password="${myApp.password}" 
p:maxActive="${myApp.maxActive}" 
p:initialSize="${myApp.initialSize}" 
/> 

<bean id="myAppSessionFactory" 
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" 
p:dataSource-ref="myAppPoolDataSource"> 
<property name="mappingResources"> 
<list> 
<value>myApp/util/TableOne.hbm.xml</value> 
<value>myApp/util/TableTwo.hbm.xml</value> 
<value>myApp/util/TableThree.hbm.xml</value> 
</list> 
</property> 
</bean> 



The oracle .jar is: 
mvn:com.oracle/ojdbc14/10.2.0.4.0 

The important properties are: 

myApp.db.driver is set to oracle.jdbc.driver.OracleDriver 
myApp.url is set to: jdbc:oracle:thin:@<ip>:<port>:sandbox 

We are using Oracle10G, Spring 3.0.3.RELEASE, Karaf 2.0.0, and 
org.apache.commons.dbcp for connection pooling. However, it appears to be 
failing inside of the Oracle driver. Any help would be greatly appreciated. I 
am unable to diagnose any further without source-code, and we would like to 
continue using Oracle for our database. 





On Wed, Oct 27, 2010 at 19:41, Mike Van < [hidden email] > wrote: 

View message @ 
http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1781852.html
 
To start a new topic under Karaf - User, email [hidden email] 
To unsubscribe from Karaf - User, click here . 

-- 
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1784093.html
 



Sent from the Karaf - User mailing list archive at Nabble.com. 



-- 
Ioannis Canellos 
http://iocanel.blogspot.com 

Integration Engineer @ Upstream S.A. 



Ioannis Canellos 
http://iocanel.blogspot.com 



View message @ 
http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1785067.html
 
To start a new topic under Karaf - User, email 
[email protected] 
To unsubscribe from Karaf - User, click here . 

-- 
View this message in context: 
http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1787887.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to