|
Dave, It looks right.
I created a local test case with your class (I stubbed out
the ones I didn't have) and your xml and it worked...
Is it possible that you are getting another error prior to
the one that you mentioned? Also can you try and simplify your test case to see
if something is masking the problem?
Abraham Fathman
From: Dave Isenhower
[mailto:disenhower@xxxxxxxxxxxxxxxxxxxxxxx] Sent: Wednesday, February
09, 2005 9:01 PM To: users@xxxxxxxxxx Subject: Re:
[cinjug-users] Bean Property not writable in Spring
Here it is:
public class
UniformWebRequestRouter implements WebRequestRouter {
protected UniformMessage mailMessage; protected
UniformMessageSender uniformMessageSender;
// list of acceptable urls to get templates
from protected List
templateLocation; protected String
templateName; public
UniformWebRequestRouter() {
}
public UniformMessage
getMailMessage() {
return mailMessage;
} public void setMailMessage( UniformMessage mailMessage
) {
this.mailMessage = mailMessage;
}
public String
getTemplateName() {
return templateName;
} public void setTemplateName( String templateName
) {
this.templateName = templateName; }
public List getTemplateLocation() {
return templateLocation;
} public void setTemplateLocation( List templateLocation
) {
this.templateLocation = templateLocation;
}
public UniformMessageSender
getUniformMessageSender() { return
uniformMessageSender; } public void
setUniformMessageSender(
UniformMessageSender uniformMessageSender)
{ this.uniformMessageSender =
uniformMessageSender; } }
Abraham
Fathman wrote:
Dave,
Can you send a copy of the webrequest.router.uniform.UniformWebRequestRouter class?
Thanks,
Abraham Fathman
Thanks, that got me over one hurdle, but now I'm
getting the same exception on a property that is not capitalized:
org.springframework.beans.NotWritablePropertyException:
Invalid property 'uniformMessageSender' of bean class
[webrequest.router.uniform.UniformWebRequestRouter]: Bean property
'uniformMessageSender' is not writable or has an invalid setter method: Does
the parameter type of the setter match the return type of the
getter?
<bean id="myRouter"
class="webrequest.router.uniform.UniformWebRequestRouter">
<property
name="uniformMessageSender">
<ref bean="myMessageSender"
/>
</property>
</bean>
<bean id="myMessageSender"
class="webrequest.router.uniform.UniformMessageSender">
<property
name="defaultUniformMessage">
<ref bean="defaultMessage" />
</property>
<property name="javaMailSender">
<ref bean="javaSender"
/>
</property>
</bean>
<bean id="defaultMessage"
class="webrequest.router.uniform.UniformMessage">
<property
name="messageTemplate">
<value>/etc/mail/uniformMessage.vm</value>
</property>
<property name="velocityEngine">
<ref bean="velocityEngine"
/>
</property> </bean>
Abraham Fathman wrote:
Dave,
I might be mistaken, but I think the property you
are trying to set should be 'messageTemplate' instead of 'MessageTemplate'
(note the lowercase m).
Sorry if it's not that, and I have overlooked
something...
Abraham Fathman 513-708-5701
I'm
having trouble wiring up a bean with Spring 1.1.4. Has anyone run into
a similar problem where you are unable to set a property because the
property is "not writable?" I here's the exception:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'defaultMessage' defined in ServletContext
resource [/WEB-INF/UniformDispatcher-servlet.xml]: Error setting property
values; nested exception is
org.springframework.beans.NotWritablePropertyException: Invalid property
'MessageTemplate' of bean class [webrequest.router.uniform.UniformMessage]:
Bean property 'MessageTemplate' is not writable or has an invalid setter
method: Does the parameter type of the setter match the return type of the
getter? at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:771)
Here
is the relevant snippet of my UniformDispatcher-servlet.xml (note: if
I comment out the defaultMessage bean, the javaSender bean sets up
OK):
<bean id="defaultMessage"
class="webrequest.router.uniform.UniformMessage">
<property
name="MessageTemplate">
<value>/etc/mail/uniformMessage.vm</value>
</property>
<property
name="VelocityEngine">
<ref bean="velocityEngine" />
</property>
</bean>
<bean
id="javaSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host">
<value>mail.somewhere.com</value>
</property>
</bean>
<bean id="velocityEngine"
class="org.apache.velocity.app.VelocityEngine"
init-method="init">
</bean>
Finally, here is the code.
public class
UniformMessage {
protected String
messageTemplate = "";
public
UniformMessage() {
}
...
public String getMessageTemplate()
{ return
messageTemplate; } public void
setMessageTemplate(String messageTemplate)
{ this.messageTemplate =
messageTemplate; }
}
Your help
would be
appreciated! Dave
|
|