Java hibernate开始事务时的空指针

Java hibernate开始事务时的空指针,java,hibernate,connection-pooling,nullpointerexception,Java,Hibernate,Connection Pooling,Nullpointerexception,我正在使用hibernate和连接池数据源 <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close"> <property name="connectionCachingEnabled" value="true" /> <property name="URL"> <value

我正在使用hibernate和连接池数据源

<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource"  destroy-method="close">
            <property name="connectionCachingEnabled" value="true" />
        <property name="URL">
            <value>${jdbc.url}</value>
        </property>
        <property name="user">
            <value>${jdbc.username}</value>
        </property>
        <property name="password">
            <value>${jdbc.password}</value>
        </property>
        <property name="connectionCacheProperties">
          <value>
            MinLimit:10
            MaxLimit:75
            InitialLimit:10
            ConnectionWaitTimeout:120
            InactivityTimeout:180
            ValidateConnection:true
            MaxStatementsLimit:0
          </value>
       </property>
    </bean>



<bean id="hibernatePropertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="hibernate.properties"/>
</bean>

<!-- Database Property -->
<bean id="hibernatePropertiesPearl"
      class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="properties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="hibernate.cache.provider_class">MyCacheProvider</prop>
            <prop key="hibernate.show_sql">false</prop>
            <prop key="hibernate.max_fetch_depth">0</prop>
            <prop key="hibernate.jdbc.batch_size">0</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory
            </prop>
            <prop key="hibernate.connection.autocommit">false</prop>
            <prop key="hibernate.transaction.manager_lookup_class">
                org.hibernate.transaction.JBossTransactionManagerLookup
            </prop>
            <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</prop>
            <prop key="hibernate.transaction.auto_close_session">false</prop>
        </props>
    </property>
</bean>
数据库中的连接数似乎正常。最大值为75,但实际上从未超过20。 部署在JBoss4.2中的应用程序。当出现空指针执行选项时,内存似乎也正常。 我觉得好像有什么东西漏了,但我不知道是什么。有没有可能,连接池认为它有75个会话,并试图增加会话数-同时db服务器只有20个连接

我无法在开发环境中复制它。我试图终止/断开会话,断开网络连接。我有不同的异常,但没有nullpointerexception。
有谁能给我一个提示,让我看看应该关注什么?

看起来您正在JTA环境中使用
org.hibernate.transaction.jdbc TransactionFactory

也许您需要
org.hibernate.transaction.JTATransactionFactory

<prop key="hibernate.transaction.factory_class">
    org.hibernate.transaction.JTATransactionFactory
</prop>

org.hibernate.transaction.JTATransactionFactory

问题在于代码中有一部分会话关闭不在finally块中。如果程序抛出hibernate错误,会话将保持打开状态。

@Boris Pavlović-我想你的评论会让你的评论毫无意义吗?:)鲍里斯-即使他删除了引用,你也在评论中重复了公司的名称!谢谢我删除了引用这是一个部署在JBOSS环境中的遗留应用程序,但它只是用作Web服务器,因此会话/事务打开/关闭在应用程序中实现。@Zoltan:那么为什么需要
hibernate.transaction.manager\u lookup\u class
,这是JTA特有的属性。它只是一个遗留的部分——曾经有一些JTA的实验,但它没有被使用。它可以被移除。
<prop key="hibernate.transaction.factory_class">
    org.hibernate.transaction.JTATransactionFactory
</prop>