Note that there are some explanatory texts on larger screens.

plurals
  1. POjava bean with static setter function
    primarykey
    data
    text
    <p>I have a web application that executes on tomcat 6.</p> <p>I have a MysqlDb class that uses a BasicDataSource from a spring JDBC.</p> <p>so far I've used the following bean configuration in <code>web.xml</code>:</p> <pre><code>&lt;bean id="MysqlDb" class="com.xpogames.gamesisland.mysql.MysqlDb"&gt; &lt;property name="idDataSource" ref="idDataSource"/&gt; &lt;/bean&gt; </code></pre> <p>and I had the following setter function:</p> <pre><code> public void setidDataSource(BasicDataSource ds) { this._dataSource=(DataSource)ds; this._simpleJdbcTemplate = new SimpleJdbcTemplate(_dataSource); this._jdbcTemplate = new JdbcTemplate(_dataSource); } </code></pre> <p>I want to convert my class to use static functions, so I created an empty private constructor so the class won't explicitly instantiated by callers.</p> <p>besides that I changed the <code>setidDataSource</code> function to a static function, but when I try to do that I get the following error:</p> <blockquote> <p>Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'idDataSource' of bean class [com.xpogames.gamesisland.mysql.MysqlDb]: Bean property 'idDataSource' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?</p> </blockquote> <p>is there a way to resolve this issue in web.xml or do I need to manually fetch the ServletContext</p> <pre><code>ServletContext servletContext = this.getServletContext(); this._context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); </code></pre> <p>and fetch the bean from there and just remove the lines i printed here from <code>web.xml</code> ?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload