Thanks Dennis, What I ended up doing was make a simple class to contain that list in a field and then put that class in my mapping. From an XML standpoint, what I was doing didn't make a whole lot of since because you can only have one root in an XML document and I was creating a bunch of rootless elements.
But some better docs on this would be nice! Overall, I'm impressed with JiBX. I hope this isn't the last application I get to use it for. Mike On 7/30/07, Dennis Sosnoski <[EMAIL PROTECTED]> wrote: > Hi Mike, > > The basic problem here is that your <mapping> is for an unmodifiable > class (java.util.ArrayList), and JiBX requires the root object to be > marshalled to be modifiable. I'm not sure if this requirement is spelled > out in the documentation, since it's not something people generally run > into. > > The particular error you're getting is kind of an indirect side effect > of the unmodifiable class. The code which throws this error predated the > idea of <mapping>s for unmodifiable classes, and when it doesn't find > any modifiable classes it assumes there weren't any <mapping>s defined > by the binding. > > I'll try to add a note to the documentation, and also provide a better > error message. To get around this in your binding, one possibility is to > create a simple subclass of ArrayList, and use that for the customer > data. Since it'll be your own subclass it'll be modifiable by the > binding compiler, and you won't have a problem. > > - 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 > > > > Mike Hostetler wrote: > > Hello, > > > > I'm a JiBX newbie, so I hope that I'm not asking something that is > > obvious but it's not obvious to me! > > > > I have a Collection of objects and I want to marshal into XML. The > > examples on SourceForge seem to have an object, and the Collection is > > on a property of that object. But that's not what I have -- I have a > > Collection and am trying to marshal it and it's contents. > > > > Here is my binding: > > <binding> > > <mapping name="customers" class="java.util.ArrayList"> > > <collection add-method="add" > > factory="com.domain.app.CustomerValue.listFactory"> > > <structure name="customer" type="com.domain.app.CustomerValue" > > > <value name="name" field="customerName"/> > > </structure> > > </collection> > > </mapping> > > </binding> > > > > My listFactory method is: > > public static List listFactory() { > > return new ArrayList(); > > } > > When I try to bind it, I get the following: > > > > [java] Error running binding compiler > > > > [java] *** Error during code generation for file > > 'jibx_bindings/ExceptionCu > > stomer.xml' - please enter a bug report for this error in Jira if the > > problem is > > not listed as fixed on the online status page *** > > > > [java] org.jibx.runtime.JiBXException: One or more <mapping> elements > > must > > be defined in <binding> > > [java] at org.jibx.binding.Utility.loadBinding(Utility.java:322) > > [java] at > > org.jibx.binding.Utility.loadFileBinding(Utility.java:413) > > [java] at org.jibx.binding.Compile.compile(Compile.java:296) > > [java] at org.jibx.binding.Compile.main(Compile.java:385) > > > > > > I'm getting all this with JiBX 1.1.5. > > > > I think the mapping element is in the right place. Is it? How do I > > bind this correctly? > > > > Thanks for helping me out . . > > > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > -- Mike Hostetler http://mike.hostetlerhome.com/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users