I am using JAXB RI 2.1.3 on JDK 1.5.0_09 and Windowx XP Pro. I have a
Java class that's been annotated with JAXB annotations. One of the
annotations is on a property of type List<String> like the following:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
@XmlRootElement(namespace="
http://www.xxx.com.tw/oakmont/soa/model/1.0")
@XmlType(namespace="
http://www.xxx.com.tw/oakmont/soa/model/1.0")
public class AvailableProductIds {
private List<String> availableProductIds;
public AvailableProductIds() {
// empty
}
@XmlElement(namespace="
http://www.xxx.com.tw/oakmont/soa/model/1.0",
name="availableProductId", required=true)
public List<String> getList() {
return availableProductIds;
}
public void setList(List<String> availableProductIds) {
this.availableProductIds = availableProductIds;
}
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Marshalling and unmarshalling this class work when I do a standalone
unit test. But if I try to marshal this class in a web app running
under Tomcat 6.0.10, i get the following exception:
Caused by: javax.xml.bind.JAXBException: class java.util.ArrayList nor
any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:540)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:460)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:230)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
at tw.com.settour.oakmont.soa.util.BindingHelper.marshal(BindingHelper.java:23)
... 20 more