Как конвертировать ArrayList <Object> в XML с помощью JAXB?
Я пытаюсь конвертировать ArrayList в XML с использованием JAXB ..
ArrayList<LDAPUser> myList = new ArrayList<LDAPUser>();
myList = retrieveUserAttributes.getUserBasicAttributes(lastName,
retrieveUserAttributes.getLdapContext());
JAXBContext jaxbContext = JAXBContext.newInstance(LDAPUser.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
StringWriter sw = new StringWriter();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(myList, sw);
System.out.println(sw.toString());
return sw.toString();
... but its not working, I am getting this error:
27-Aug-2012 10:43:58 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [spring] in context with path [/Spring3-LDAP-WebService] threw exception [Request processing failed; nested exception is javax.xml.bind.JAXBException: class java.util.ArrayList nor any of its super class is known to this context.] with root cause javax.xml.bind.JAXBException: class java.util.ArrayList nor any of its super class is known to this context. at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:554) at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:470) at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314) at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96) at ie.revenue.spring.RestController.searchLdapUsersByLastNameTwo(RestController.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)...........
Пожалуйста помоги! Благодарю.