A robust starter web application to ease Java webapp development.

Home | Tutorials | Demos | Issues

Additional data source causing org.apache.commons.dbcp.SQLNestedException

View: New views
3 Messages — Rating Filter:   Alert me  

Additional data source causing org.apache.commons.dbcp.SQLNestedException

by cfoy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I needed to add an additional data source to an appfuse 2.0 spring MVC & hibernate project.  However after a few days of extremely light usage of the data source in product the following exception is thrown:

org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool error Timeout waiting for idle object
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:104)
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)

I set up the second data source as follows by adding beans for a HibernateTransactionManager, a AnnotationSessionFactoryBean and a BasicDataSource:



   <bean id="dataSourceReporting" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="jdbc:oracle:thin:@10.XX.XX.XX:1521:XE"/>
        <property name="username" value="SYSTEM"/>
        <property name="password" value="password"/>
        <property name="maxActive" value="100"/>
        <property name="maxWait" value="1000"/>
        <property name="poolPreparedStatements" value="true"/>
        <property name="defaultAutoCommit" value="true"/>
    </bean>

    <!-- Hibernate SessionFactory For Reporting Data Base -->
    <bean id="sessionFactoryReporting" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSourceReporting"/>
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=${hibernate.dialect}
                hibernate.query.substitutions=true 'Y', false 'N'
                hibernate.cache.use_second_level_cache=true
                hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
            </value>
        </property>
    </bean>

    <bean id="transactionManagerReporting" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactoryReporting"/>
    </bean>

The dao that accesses this data source extends GenericDaoHibernate.  The dao uses getSession().createSQLQuery.  I am not closing these connections as I far as I understand that once the transaction is complete the spring will close the connection for me as the session is bound to the thread.  

Has anyone any idea of what the problem might be?

Cheers

Abu

Re: Additional data source causing org.apache.commons.dbcp.SQLNestedException

by mraible :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If it happens after a few days, it's probably not a configuration issue, but more of a firewall or timeout issue with the Oracle driver.

Matt

On Mon, Jun 23, 2008 at 6:46 AM, cfoy <cfoy.c@...> wrote:

Hi All,

I needed to add an additional data source to an appfuse 2.0 spring MVC &
hibernate project.  However after a few days of extremely light usage of the
data source in product the following exception is thrown:

org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool
error Timeout waiting for idle object
at
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:104)
       at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
       at
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)

I set up the second data source as follows by adding beans for a
HibernateTransactionManager, a AnnotationSessionFactoryBean and a
BasicDataSource:



  <bean id="dataSourceReporting"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
       <property name="driverClassName" value="${jdbc.driverClassName}"/>
       <property name="url" value="jdbc:oracle:thin:@10.XX.XX.XX:1521:XE"/>
       <property name="username" value="SYSTEM"/>
       <property name="password" value="password"/>
       <property name="maxActive" value="100"/>
       <property name="maxWait" value="1000"/>
       <property name="poolPreparedStatements" value="true"/>
       <property name="defaultAutoCommit" value="true"/>
   </bean>

   <!-- Hibernate SessionFactory For Reporting Data Base -->
   <bean id="sessionFactoryReporting"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
       <property name="dataSource" ref="dataSourceReporting"/>
       <property name="configLocation"
value="classpath:hibernate.cfg.xml"/>
       <property name="hibernateProperties">
           <value>
               hibernate.dialect=${hibernate.dialect}
               hibernate.query.substitutions=true 'Y', false 'N'
               hibernate.cache.use_second_level_cache=true

hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
           </value>
       </property>
   </bean>

   <bean id="transactionManagerReporting"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactoryReporting"/>
   </bean>

The dao that accesses this data source extends GenericDaoHibernate.  The dao
uses getSession().createSQLQuery.  I am not closing these connections as I
far as I understand that once the transaction is complete the spring will
close the connection for me as the session is bound to the thread.

Has anyone any idea of what the problem might be?

Cheers

Abu
--
View this message in context: http://www.nabble.com/Additional-data-source-causing-org.apache.commons.dbcp.SQLNestedException-tp18067093s2369p18067093.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: Additional data source causing org.apache.commons.dbcp.SQLNestedException

by cfoy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Matt,

I increased the max wait timeout for the commons pool data source to 30 seconds and I haven't seen the error since.  

BTW I also used wrapped my native sql queries via session.createSQLQuery in a HibernateCallback as I was concerned that the sessions were not being closed.  

Appreciate the help.  

Abu

mraible wrote:
If it happens after a few days, it's probably not a configuration issue, but
more of a firewall or timeout issue with the Oracle driver.

Matt

On Mon, Jun 23, 2008 at 6:46 AM, cfoy <cfoy.c@stc.com.sa> wrote:

>
> Hi All,
>
> I needed to add an additional data source to an appfuse 2.0 spring MVC &
> hibernate project.  However after a few days of extremely light usage of
> the
> data source in product the following exception is thrown:
>
> org.apache.commons.dbcp.SQLNestedException: Cannot get a connection, pool
> error Timeout waiting for idle object
> at
>
> org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:104)
>        at
>
> org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
>        at
>
> org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
>
> I set up the second data source as follows by adding beans for a
> HibernateTransactionManager, a AnnotationSessionFactoryBean and a
> BasicDataSource:
>
>
>
>   <bean id="dataSourceReporting"
> class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
>        <property name="driverClassName" value="${jdbc.driverClassName}"/>
>        <property name="url" value="jdbc:oracle:thin:@10.XX.XX.XX
> :1521:XE"/>
>        <property name="username" value="SYSTEM"/>
>        <property name="password" value="password"/>
>        <property name="maxActive" value="100"/>
>        <property name="maxWait" value="1000"/>
>        <property name="poolPreparedStatements" value="true"/>
>        <property name="defaultAutoCommit" value="true"/>
>    </bean>
>
>    <!-- Hibernate SessionFactory For Reporting Data Base -->
>    <bean id="sessionFactoryReporting"
>
> class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
>        <property name="dataSource" ref="dataSourceReporting"/>
>        <property name="configLocation"
> value="classpath:hibernate.cfg.xml"/>
>        <property name="hibernateProperties">
>            <value>
>                hibernate.dialect=${hibernate.dialect}
>                hibernate.query.substitutions=true 'Y', false 'N'
>                hibernate.cache.use_second_level_cache=true
>
> hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
>            </value>
>        </property>
>    </bean>
>
>    <bean id="transactionManagerReporting"
> class="org.springframework.orm.hibernate3.HibernateTransactionManager">
>        <property name="sessionFactory" ref="sessionFactoryReporting"/>
>    </bean>
>
> The dao that accesses this data source extends GenericDaoHibernate.  The
> dao
> uses getSession().createSQLQuery.  I am not closing these connections as I
> far as I understand that once the transaction is complete the spring will
> close the connection for me as the session is bound to the thread.
>
> Has anyone any idea of what the problem might be?
>
> Cheers
>
> Abu
> --
> View this message in context:
> http://www.nabble.com/Additional-data-source-causing-org.apache.commons.dbcp.SQLNestedException-tp18067093s2369p18067093.html
> Sent from the AppFuse - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@appfuse.dev.java.net
> For additional commands, e-mail: users-help@appfuse.dev.java.net
>
>
LightInTheBox - Buy quality products at wholesale price!