I wanted to switch over all my uses of [] arrays to collections. I'm doing what I think is the exact same thing in two different places, and in one case it's throwing an UnsupportedOperationException from AbstractList.add. Maybe someone can see where I'm messing up.
This is using JiBX as databinding for an Axis2 web service client and server. The situation that works: class: public class DataDiscoveryResponse { public List<DataItem> dataItems = new ArrayList<DataItem>(); // The following is required for JiBX because we're using the List interface. private static List<DataItem> buildDataItems() { return new ArrayList<DataItem>(); } } mapping: <mapping type-name="esdp:DataDiscoveryResponseType" abstract="true" class="edu.iris.ws.esdp.DataDiscoveryResponse"> <collection field="dataItems" usage="optional" factory="edu.iris.ws.esdp.DataDiscoveryResponse.buildDataItems"> </collection> </mapping> msg: <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <esdp:listDataResponse xmlns:gml="http://www.opengis.net/gml" xmlns:esdp="http://portal.earthscope.org"> <esdp:DataItem xmlns:ogc="http://www.opengis.net/ogc"> [snip] </esdp:DataItem> </esdp:listDataResponse> etc. The situation that doesn't work: class: public class StationDiscoveryResponse { public List<StationInfo> stations = new ArrayList<StationInfo>(); // required by JiBX private static List<StationInfo>buildStations() { System.out.println("new station list."); return new ArrayList<StationInfo>(); } } mapping: <mapping type-name="esdp:StationDiscoveryResponseType" abstract="true" class="edu.iris.ws.esdp.StationDiscoveryResponse"> <structure name="Stations"> <collection field="stations" usage="optional" factory="edu.iris.ws.esdp.StationDiscoveryResponse.buildStations"> <structure name="Station" map-as="esdp:StationInfoType"/> </collection> </structure> </mapping> msg: <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <esdp:getStationsResponse xmlns:gml="http://www.opengis.net/gml" xmlns:esdp="http://portal.earthscope.org"> <esdp:Stations> <esdp:Station> [snip] </esdp:Station> </esdp:Stations> etc. The exception trace is: [java] java.lang.UnsupportedOperationException [java] at java.util.AbstractList.add(AbstractList.java:151) [java] at java.util.AbstractList.add(AbstractList.java:89) [java] at edu.iris.ws.esdp.JiBX_MungeAdapter.JiBX_binding_unmarshal_1_0() [java] at edu.iris.ws.esdp.StationInfo.JiBX_binding_unmarshal_1_0(Unknown Source) [java] at edu.iris.ws.esdp.JiBX_MungeAdapter.JiBX_binding_unmarshal_1_3() [java] at edu.iris.ws.esdp.StationDiscoveryResponse.JiBX_binding_unmarshal_1_0(Unknown Source) [java] at edu.iris.ws.esdp.StationDiscoveryResponse.JiBX_binding_unmarshal_1_1(Unknown Source) [java] at edu.iris.ws.esdp.JiBX_bindingStationDiscoveryResponse_access.unmarshal() [java] at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2512) [java] at edu.iris.ws.esdp.ESPortalCDIStub.fromOM(ESPortalCDIStub.java:1222) [java] at edu.iris.ws.esdp.ESPortalCDIStub.getStations(ESPortalCDIStub.java:231) [java] at edu.iris.ws.esdp.WebServiceClient.performStationQuery(WebServiceClient.java:306) [java] at edu.iris.ws.esdp.WebServiceClient.performStationQuery(WebServiceClient.java:341) [java] at edu.iris.ws.esdp.WebServiceClient.main(WebServiceClient.java:421) [java] org.apache.axis2.AxisFault [java] at edu.iris.ws.esdp.ESPortalCDIStub.fromOM(ESPortalCDIStub.java:1225) [java] at edu.iris.ws.esdp.ESPortalCDIStub.getStations(ESPortalCDIStub.java:231) [java] at edu.iris.ws.esdp.WebServiceClient.performStationQuery(WebServiceClient.java:306) [java] at edu.iris.ws.esdp.WebServiceClient.performStationQuery(WebServiceClient.java:341) [java] at edu.iris.ws.esdp.WebServiceClient.main(WebServiceClient.java:421) The factory method is getting called, I can see. So where is the AbstractList coming from? So the only difference that I can see is that the failing case is wrapped in another element. I've tried both with the collection originally null and setting it explicitly to an ArrayList. I've tried using the create-type instead of factory method. I'm using JiBX 1.1.5 thanks a lot, Linus ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users