Thanks Dennis. I was barking up the wrong tree. Well, I was barking at the tree when I should have been looking at a branch. It was a collection of Enums inside the StationInfo that I was doing wrong somehow. Cleaning that all up made it happy.
thanks, Linus Dennis Sosnoski wrote: > Hi Linus, > > First off, let me point out that you don't need the List factory methods > in these classes. You can instead use create-type="java.util.ArrayList" > on the <collection> element of the binding. Note that you don't need to > worry about generics for this - Java 5 generics are essentially only a > source code artifact, and you can just use the base ArrayList type for JiBX. > > That said, I don't see why you'd be getting the exception here. But from > the stack trace, the exception is occurring *inside* the unmarshalling > of a StationInfo (since StationInfo.JiBX_binding_unmarshal_1_0 is one of > the methods in the trace), so I think the problem is actually with a > List inside the StationInfo class. > > Hope that helps, > > - Dennis > > Dennis M. Sosnoski > SOA and Web Services in Java > Training and Consulting > http://www.sosnoski.com - http://www.sosnoski.co.nz > Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 > > > > Linus Kamb wrote: >> 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 >> >> > > ------------------------------------------------------------------------- > 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 ------------------------------------------------------------------------- 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