无法从连接池获取/创建连接

时间:2012-02-24 10:01:29

标签: java oracle jdbc glassfish connection-pooling

我正在使用primefaces 3.1

运行glassfish 3

知道我为什么会遇到这个例外吗?当我第一次创建数据源并运行它运行正常但在一段时间后这个错误开始出现。

WARNING: RAR5117 : Failed to obtain/create connection from connection pool [ Oracle_TSH1_Pool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException
WARNING: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: null]
SEVERE: java.sql.SQLException: Error in allocating a connection. Cause: null
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:120)
    at MYDataSource.getConnection(DatabaseConnection.java:65)
    at ScheduleDAO.loadSchedules(ScheduleDAO.java:48)
    at SchedulesBean.getSchedules(SchedulesBean.java:42)
    at SchedulesBean.<init>(SchedulesBean.java:28)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:188)
    at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:102)
    at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
    at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
    at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
    at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:99)
    at com.sun.el.parser.AstValue.getTarget(AstValue.java:127)
    at com.sun.el.parser.AstValue.getType(AstValue.java:76)
    at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:195)
    at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
    at org.primefaces.component.datatable.DataTable.isLazy(DataTable.java:922)
    at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:177)
    at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:103)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1763)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)

我的glassfish-resource.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" "http://www.sun.com/software/appserver/dtds/sun-resources_1_3.dtd">
<resources>
    <jdbc-resource enabled="true" jndi-name="jdbc/myDS"
        object-type="user" pool-name="Oracle_Pool" />

    <jdbc-connection-pool allow-non-component-callers="false"
        associate-with-thread="false" connection-creation-retry-attempts="0"
        connection-creation-retry-interval-in-seconds="10"
        connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0"
        connection-validation-method="auto-commit" datasource-classname="oracle.jdbc.pool.OracleDataSource"
        fail-all-connections="false" idle-timeout-in-seconds="300"
        is-connection-validation-required="false"
        is-isolation-level-guaranteed="true" lazy-connection-association="false"
        lazy-connection-enlistment="false" match-connections="false"
        max-connection-usage-count="0" max-pool-size="32"
        max-wait-time-in-millis="60000" name="Oracle_Pool"
        non-transactional-connections="false" pool-resize-quantity="2"
        res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1"
        steady-pool-size="8" validate-atmost-once-period-in-seconds="0"
        wrap-jdbc-objects="false">

        <property name="serverName" value="server" />

        <property name="PortNumber" value="1521" />

        <property name="DatabaseName" value="mydb" />

        <property name="User" value="user" />


        <property name="URL" value="jdbc:oracle:thin:@server:1521:mydb" />

        <property name="driverClass" value="oracle.jdbc.OracleDriver" />

    </jdbc-connection-pool>
</resources>

1 个答案:

答案 0 :(得分:2)

我通过将ojdbc14.jar复制到glassfish\domains\domain1\lib\ext

来解决了问题