类'oracle.jdbc.xa.client.OracleXADataSource'中没有可写属性'url'

时间:2014-12-11 15:41:56

标签: spring java-ee jdbc jta atomikos

我正在为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

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

1 个答案:

答案 0 :(得分:4)

事实证明,只需将资产名称URL大写。从Oracle API documentOracleXADataSource有一个setter方法为setURL(),因此bean名称应该使用

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

而不是

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

干杯..