tfbbt8
tfbbt8

Reputation: 335

Spring MVC no setter found for property 'xxxx' in class 'xxxx'

I'm getting four 'no setter found for property 'xxxx' in class com.rusapp.batch.trans.OLFMWriter'. A fifth bean in that class does not have an error, inputQueue. The rest have errors in the xml below at each of the property lines.

The beans appear as such:

<bean id="inputQueue" class="com.rusapp.batch.trans.OLFMWriter">
    <property name="inputQueue" value="${${ENV}_MQ_FM_INPUT_QUEUE}" />
</bean>

<bean id="replyQueue" class="com.rusapp.batch.trans.OLFMWriter">
    <property name="replyQueue" value="${${ENV}_MQ_FM_REPLY_QUEUE}" />
</bean>

<bean id="mqConnectionFactory" class="com.rusapp.batch.trans.OLFMWriter">
    <property name="mqConnectionFactory" ref="mqConnection" />
</bean>

<bean id="JMSDestination"
    class="com.rusapp.batch.trans.OLFMWriter">
    <property name="JMSDestination" ref="jmsDestinationResolver" />
</bean>

<bean id="JMSReplyTo"
    class="com.rusapp.batch.trans.OLFMWriter">
    <property name="JMSReplyTo" ref="jmsDestinationResolverReceiver" />
</bean>

The setters in the class appear as follows:

public static void setMqConnectionFactory(MQConnectionFactory _mqConnectionFactory) {
    OLFMWriter._mqConnectionFactory = _mqConnectionFactory;
}
public static void setReplyQueue(String _replyQueue) {
    OLFMWriter._replyQueue = _replyQueue;
}
public static void setJMSDestination(Destination _JMSDestination) {
    OLFMWriter._JMSDestination = _JMSDestination;
}
public static void setJMSReplyTo(Destination _JMSReplyTo) {
    OLFMWriter._JMSReplyTo = _JMSReplyTo;
}
public void setInputQueue(String inputQueue){
    _inputQueue = inputQueue;
}

This is not my code and I'm not too knowledgeable with Spring yet but I can't find anything wrong with the setter names. I thought it was a workspace error but they have persisted through several restarts of Eclipse.

Can anyone find any obvious faults with this code?

Upvotes: 0

Views: 2617

Answers (1)

lance-java
lance-java

Reputation: 27984

Your setters are static which means that they don't conform to the java beans specification.

I think you'll want to use a MethodInvokingFactorybean instead.

<bean abstract="true" id="abstractParent" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetClass" value="com.rusapp.batch.trans.OLFMWriter"/>
</bean>
<bean id="inputQueue" parent="abstractParent">
    <property name="staticMethod" value="setInputQueue" />
    <property name="arguments">
        <list><value>${${ENV}_MQ_FM_INPUT_QUEUE}</value></list>
    </property>
</bean>
<bean id="replyQueue" parent="abstractParent">
    <property name="staticMethod" value="setReplyQueue" />
    <property name="arguments">
        <list><value>${${ENV}_MQ_FM_REPLY_QUEUE}</value></list>
    </property>
</bean>
etc...

Upvotes: 3

Related Questions