【问题标题】:no writeable property 'url' in class 'oracle.jdbc.xa.client.OracleXADataSource'“oracle.jdbc.xa.client.OracleXADataSource”类中没有可写属性“url”
【发布时间】:2014-12-11 15:41:56
【问题描述】:

我正在为 Atomikos 编写 Spring 应用程序的 JTA 事务管理模块,假设一切都已正确设置:

<bean id="dataSource_JDBC_01" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
    <property name="uniqueResourceName"><value>dataSource01</value></property>
    <property name="xaDataSourceClassName"><value>${database_01.xadriver}</value></property>
    <property name="xaProperties">
        <props>
        <prop key="databaseName">${database_01.username}</prop>
        <prop key="user">${database_01.username}</prop>
        <prop key="password">${database_01.password}</prop>
        <prop key="url">${database_01.url}</prop>
        </props>
    </property>
    <property name="poolSize"><value>1</value></property>
</bean>

<jee:jndi-lookup id="dataSource_01" jndi-name="jdbc/DataSource01" default-ref="dataSource_JDBC_01" />

从这里引用这些占位符的值:

database_01.xadriver=oracle.jdbc.xa.client.OracleXADataSource
database_01.url=jdbc\:oracle\:thin\:@localhost\:1521\:orcl
database_01.username=USER_01
database_01.password=PASS_01

但是Atomikos抛出异常:

no writeable property 'url' in class 'oracle.jdbc.xa.client.OracleXADataSource'
2014-12-11 12:00:23,098 -- WARN -- com.atomikos.jdbc.AtomikosSQLException -- Cannot initialize AtomikosDataSourceBean
com.atomikos.beans.PropertyException: no writeable property 'url' in class 
'oracle.jdbc.xa.client.OracleXADataSource'
at com.atomikos.beans.PropertyUtils.getSetter(PropertyUtils.java:286)
at com.atomikos.beans.PropertyUtils.setDirectProperty(PropertyUtils.java:200)
at com.atomikos.beans.PropertyUtils.setProperty(PropertyUtils.java:110)
at com.atomikos.beans.PropertyUtils.setProperties(PropertyUtils.java:186)

接着是:

javax.naming.NamingException: Another resource already exists with name dataSource01 - pick a different name

我真的不知道这里出了什么问题。

【问题讨论】:

    标签: spring jakarta-ee jdbc jta atomikos


    【解决方案1】:

    原来只是将属性名称URL 大写的问题。从Oracle API documentOracleXADataSource 有一个setter 方法为setURL(),所以bean 名称应该使用

    <prop key="URL">${database_01.url}</prop>
    

    而不是

    <prop key="url">${database_01.url}</prop>
    

    干杯..

    【讨论】:

      猜你喜欢
      • 2016-05-11
      • 2016-08-30
      • 1970-01-01
      • 2013-11-30
      • 2018-07-01
      • 1970-01-01
      • 2017-06-21
      • 2015-03-02
      • 1970-01-01
      相关资源
      最近更新 更多