Back Forum Reply New

Bean Definition for Marshaller

Hi,

Petclinic Roo is running fine for me. I added a marshaller/unmarshaller to translate to/from XML to POJO object from from messages.

In my webmvc_config.xml, I added:
       lt;bean id=quot;frommsgquot; class=quot;org..web.servlet.view.xml.Ma  rshallingViewquot;gt;    lt;property name=quot;contentTypequot; value=quot;application/xmlquot;/gt;    lt;property name=quot;marshallerquot; ref=quot;marshallerquot;/gt;       lt;/beangt;
   lt;bean id=quot;marshallerquot; class=quot;org..oxm.jaxb.Jaxb2Marshalle  rquot;         p:contextPath=quot;com.bzinc.demoBackup.domain.fromMsg  quot; /gt;

lt;!--        lt;bean id=quot;jaxb2Marshallerquot; class=quot;org..oxm.jaxb.Jaxb2Marshalle  rquot;gt;       lt;property name=quot;classesToBeBoundquot;gt;          lt;listgt;    lt;valuegt;com.bzinc.demoBackup.domain.fromMsglt;/valuegt;lt;/listgt;        lt;/propertygt;        lt;property name=quot;schemaquot; value=quot;classpath:fromMsg.xsdquot;/gt;   lt;/beangt;
--gt;
       lt;bean class=quot;org..web.servlet.mvc.annotat  ion.AnnotationMethodHandlerAdapterquot;gt;lt;property name=quot;messageConvertersquot;gt;  lt;listgt;    lt;ref bean=quot;marshallingfromMessageConverterquot;/gt;  lt;/listgt;lt;/propertygt;       lt;/beangt;
       lt;bean id=quot;marshallingfromMessageConverterquot;   class=quot;org..from.converter.xml.Mars  hallingfromMessageConverterquot;gt;         lt;property name=quot;marshallerquot; ref=quot;marshallerquot; /gt;         lt;property name=quot;unmarshallerquot; ref=quot;marshallerquot; /gt;       lt;/beangt;
I get this error (tried numerous variations of defining Marshaller):

Caused by: org..oxm.jaxb.JaxbSystemException: quot;com.bzinc.demoBackup.domain.fromMsgquot; doesnt contain ObjectFactory.class or jaxb.index; nested exception is javax.xml.bind.JAXBException: quot;com.bzinc.demoBackup.domain.fromMsgquot; doesnt contain ObjectFactory.class or jaxb.index

How should I define the marshaller and unmarshaller in my webmvc_config.xml file?

Many Thanks in Advance...

I am not an expert on this. Maybe you should take a look at the Spring Web Services documentation for details: sprin...html#oxm-usage

Another option is to use the Spring 3 ContentNegotiatingViewResolver in combination with XStream. I have explained this here: showth... gViewResolver

HTH,
Stefan

Thank you very much for the info, Stefan.

Although still not entirely sure why, my problem disappeared after I took out the property quot;schemaquot; from the jaxb2Marshaller bean definition:

lt;property name=quot;schemaquot; value=quot;classpath:fromMsg.xsdquot;/gt;

I'll read up to find more details.

Thanks again :-)
¥
Back Forum Reply New