You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Mike Van <mv...@comcast.net> on 2010/10/27 19:41:45 UTC

Karaf Spring Hibernate DBCP issue

The folks on the Karaf IRC channel suggested I post this here in order to get
more feedback.  Basically, I'm using hibernate, spring, and the spring dbcp
connection pool to connect to Oracle and get the following error:

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)


For reference, The following information should help:

>From my applicationContext.xml file:
<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>

And:

The oracle .jar is:
mvn:com.oracle/ojdbc14/10.2.0.4.0
myApp.db.driver is set to oracle.jdbc.driver.OracleDriver 
myApp.url is set to: jdbc:oracle:thin:@<ip>:<port>:sandbox
-- 
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1781634.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf Spring Hibernate DBCP issue

Posted by Ioannis Canellos <io...@gmail.com>.
If you are going to used Managed Data Source the transaction manager is
required. However, you are not forced to. I just pasted you with a working
example of my own.

Regarding the transaction manager bean, you can you aries transaction (which
is a wrapper of the geronimo transaction manager).

On Thu, Oct 28, 2010 at 8:53 PM, Mike Van <mv...@comcast.net> wrote:

>
>
>
> 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]" <
> ml-node+1785067-558007141-228489@n3.nabble.com<ml...@n3.nabble.com>
> >
> To: "Mike Van" <mv...@comcast.net>
> 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
> ml-node+930749-917263437-228489@n3.nabble.com<ml...@n3.nabble.com>
> 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.
>



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

Integration Engineer @ Upstream S.A. <http://www.upstreamsystems.com>

Re: Karaf Spring Hibernate DBCP issue

Posted by Mike Van <mv...@comcast.net>.
Gents, none of this worked. Since my project has been highly refactored since
I first started down this road, I'm going to punt this for a week or so and
come back to it using the new database implementation.  Hopefully, that
won't be as butt-hurt.
-- 
View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1788482.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Karaf Spring Hibernate DBCP issue

Posted by Johan Edstrom <se...@gmail.com>.
The validation query is simply something like SELECT 1 from dual
Just to check the connection and validate it.

On Oct 28, 2010, at 11:53 AM, Mike Van wrote:

> validationQuery

Johan Edstrom

joed@opennms.org

They that can give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety.

Benjamin Franklin, Historical Review of Pennsylvania, 1759






Re: Karaf Spring Hibernate DBCP issue

Posted by Mike Van <mv...@comcast.net>.


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]" <ml...@n3.nabble.com> 
To: "Mike Van" <mv...@comcast.net> 
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 ml-node+930749-917263437-228489@n3.nabble.com 
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.

Re: Karaf Spring Hibernate DBCP issue

Posted by Ioannis Canellos <io...@gmail.com>.
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 <mv...@comcast.net> 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
> ml-node+930749-917263437-228489@n3.nabble.com<ml...@n3.nabble.com>
> 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. <http://www.upstreamsystems.com>

Re: Karaf Spring Hibernate DBCP issue

Posted by Mike Van <mv...@comcast.net>.


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 ml-node+930749-917263437-228489@n3.nabble.com 
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.

Re: Karaf Spring Hibernate DBCP issue

Posted by Guillaume Nodet <gn...@gmail.com>.
Do you use a security manager ?
I googled a bit and found
https://issues.apache.org/bugzilla/show_bug.cgi?id=49178 but not sure
if it's related.  The other similar stack traces I've found had no
real answers.

On Wed, Oct 27, 2010 at 19:41, Mike Van <mv...@comcast.net> wrote:
>
> The folks on the Karaf IRC channel suggested I post this here in order to get
> more feedback.  Basically, I'm using hibernate, spring, and the spring dbcp
> connection pool to connect to Oracle and get the following error:
>
> 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)
>
>
> For reference, The following information should help:
>
> From my applicationContext.xml file:
> <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>
>
> And:
>
> The oracle .jar is:
> mvn:com.oracle/ojdbc14/10.2.0.4.0
> myApp.db.driver is set to oracle.jdbc.driver.OracleDriver
> myApp.url is set to: jdbc:oracle:thin:@<ip>:<port>:sandbox
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Karaf-Spring-Hibernate-DBCP-issue-tp1781634p1781634.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com