siuyiuyiu
Nov 3rd, 2006, 07:07 AM
Hi, I would like to use org.springframework.oxm.castor.CastorMarshaller to convert an xml file into object class.
I have already set the value of set-method and get-method directly in the mapping.xml file, but it seems not able to write it.
e.g.
<field name="Xmlns" set-method="setXmlns" get-method="getXmlns" type="java.lang.String">
<bind-xml name="xmlns" node="attribute"/>
</field>
I'm not sure because the object class consists of other methods which are not for the converting into xml structure or not.
===========error================
[junit] Testcase: warning(junit.framework.TestSuite$1): FAILED
[junit] Exception in constructor: testUnmarshal (org.springframework.beans.factory.BeanCreationE
xception: Error creating bean with name 'etefitnessProtocol' defined in class path resource [applica
tionContext-testmar.xml]: Error setting property values; nested exception is org.springframework.bea
ns.NotWritablePropertyException: Invalid property 'unmarshaller' of bean class [ch.fhnw.efitness.ser
ver.domain.EtefitnessProtocol]: Bean property 'unmarshaller' is not writable or has an invalid sette
r method. Does the parameter type of the setter match the return type of the getter?
[junit] Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'unm
arshaller' of bean class [ch.fhnw.efitness.server.domain.EtefitnessProtocol]: Bean property 'unmarsh
aller' is not writable or has an invalid setter method. Does the parameter type of the setter match
the return type of the getter?
[junit] at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:7
51)
[junit] at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:6
08)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValue(AbstractPrope
rtyAccessor.java:49)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractProp
ertyAccessor.java:74)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractProp
ertyAccessor.java:57)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.appl
yPropertyValues(AbstractAutowireCapableBeanFactory .java:970)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.popu
lateBean(AbstractAutowireCapableBeanFactory.java:7 29)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.crea
teBean(AbstractAutowireCapableBeanFactory.java:416 )
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(Abstrac
tBeanFactory.java:245)
[junit] at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSinglet
on(DefaultSingletonBeanRegistry.java:141)
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBea
nFactory.java:242)
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBea
nFactory.java:156)
[junit] at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantia
teSingletons(DefaultListableBeanFactory.java:290)
[junit] at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractAp
plicationContext.java:348)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:92)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:77)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:68)
[junit] at ch.fhnw.efitness.server.mar.test.TestAttachment.<init>(TestAttachment.java:41)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorIm
pl.java:39)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAc
cessorImpl.java:27)
[junit] at java.lang.reflect.Constructor.newInstance(Construc tor.java:506)
I have already set the value of set-method and get-method directly in the mapping.xml file, but it seems not able to write it.
e.g.
<field name="Xmlns" set-method="setXmlns" get-method="getXmlns" type="java.lang.String">
<bind-xml name="xmlns" node="attribute"/>
</field>
I'm not sure because the object class consists of other methods which are not for the converting into xml structure or not.
===========error================
[junit] Testcase: warning(junit.framework.TestSuite$1): FAILED
[junit] Exception in constructor: testUnmarshal (org.springframework.beans.factory.BeanCreationE
xception: Error creating bean with name 'etefitnessProtocol' defined in class path resource [applica
tionContext-testmar.xml]: Error setting property values; nested exception is org.springframework.bea
ns.NotWritablePropertyException: Invalid property 'unmarshaller' of bean class [ch.fhnw.efitness.ser
ver.domain.EtefitnessProtocol]: Bean property 'unmarshaller' is not writable or has an invalid sette
r method. Does the parameter type of the setter match the return type of the getter?
[junit] Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'unm
arshaller' of bean class [ch.fhnw.efitness.server.domain.EtefitnessProtocol]: Bean property 'unmarsh
aller' is not writable or has an invalid setter method. Does the parameter type of the setter match
the return type of the getter?
[junit] at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:7
51)
[junit] at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:6
08)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValue(AbstractPrope
rtyAccessor.java:49)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractProp
ertyAccessor.java:74)
[junit] at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractProp
ertyAccessor.java:57)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.appl
yPropertyValues(AbstractAutowireCapableBeanFactory .java:970)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.popu
lateBean(AbstractAutowireCapableBeanFactory.java:7 29)
[junit] at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.crea
teBean(AbstractAutowireCapableBeanFactory.java:416 )
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(Abstrac
tBeanFactory.java:245)
[junit] at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSinglet
on(DefaultSingletonBeanRegistry.java:141)
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBea
nFactory.java:242)
[junit] at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBea
nFactory.java:156)
[junit] at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantia
teSingletons(DefaultListableBeanFactory.java:290)
[junit] at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractAp
plicationContext.java:348)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:92)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:77)
[junit] at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPa
thXmlApplicationContext.java:68)
[junit] at ch.fhnw.efitness.server.mar.test.TestAttachment.<init>(TestAttachment.java:41)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorIm
pl.java:39)
[junit] at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAc
cessorImpl.java:27)
[junit] at java.lang.reflect.Constructor.newInstance(Construc tor.java:506)