Dreamer
Dreamer

Reputation: 7551

no writeable property 'url' in class 'oracle.jdbc.xa.client.OracleXADataSource'

I am writing a JTA transaction management module for the Spring application by Atomikos, everything assumed to be properly setup:

<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" />

Values to those placeholders are quoted from here:

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

But Atomikos throw an exception:

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)

Followed by:

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

I really cannot tell what is wrong here.

Upvotes: 0

Views: 3296

Answers (1)

Dreamer
Dreamer

Reputation: 7551

Turns out it just a matter of capitalize the name of property URL. From Oracle API document class OracleXADataSource has a setter method as setURL(), so that the bean name should use

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

instead of

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

Cheers..

Upvotes: 4

Related Questions