Hi, I'm having a problem with the speed of marshalling objects to XML, and it seems strange to me that when I supply a mapping file to the marshaller the marshal(Object) method actually takes longer to execute than when I don't supply a mapping (so it marshals by introspection).
Here is my code with the timing of the .marshal(Object) method: StringWriter sw = new StringWriter(); Marshaller marshaller = new Marshaller(sw); marshaller.setMarshalAsDocument(false); marshaller.setSuppressXSIType (true); marshaller.setValidation(false); marshaller.setMapping(mapping); Date then = new Date(); marshaller.marshal(this); long ms = new Date().getTime() - then.getTime(); However if I replace " marshaller.marshal(this);" with "Marshaller.marshal(this, sw);" so it uses introspection instead of the specified mapping then the method completes way quicker. In fact it takes up to a second to marshal the object and they are not very large or complex objects so I suspect something is wrong. I would have thought that introspection would be slower. I've tried all the techniques such as caching a ClassDescriptorResolver but the slow execution is actually when marshalling with the marshal(Object) method and not the loading of the mapping file etc. Maybe there is something wrong with the mapping file I'm using? Here is is: <?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version 1.0//EN" " http://castor.org/mapping.dtd"> <mapping> <description>Mapping of CwsResult and associated classes</description> <class name=" util.result.SelectionData"> <map-to xml="SELECTION_DATA" /> <field name="query" set-method="setQuery" get-method="getQuery" type="string" > <bind-xml name="QUERY" node="element" /> </field> <field name="snippet" set-method="setSnippet" get-method="getSnippet" type="string"> <bind-xml name="SNIPPET" node="element" /> </field> <field name="timestamp" set-method="setTimestamp" get-method="getTimestamp" type="date" > <bind-xml name="TIMESTAMP" node="attribute" /> </field> </class> <class name="util.result.RecommenderSelectionData "> <map-to xml="RECOMMENDER_SELECTION_DATA" /> <field name="score" set-method="setScore" get-method="getScore" type="double" > <bind-xml name="SCORE" node="element" /> </field> <field name="selections" set-method="setSelections" get-method="getSelections" type=" util.result.SelectionData" collection="arraylist"> <bind-xml name="SELECTIONS" node="element" /> </field> <field name="userId" set-method="setUserId" get-method="getUserId" type="long" > <bind-xml name="USERID" node="attribute" /> </field> </class> <class name=" util.result.CwsResult"> <map-to xml="RESULT" /> <field name="title" set-method="setTitle" get-method="getTitle" type="string" > <bind-xml name="TITLE" node="element" /> </field> <field name="displaySnippet" set-method="setDisplaySnippet" get-method="getDisplaySnippet" type="string" > <bind-xml name="DISPLAY_SNIPPET" node="element" /> </field> <field name="displayUrl" get-method="getDisplayUrl" type="string" > <bind-xml name="DISPLAY_URL" node="element" /> </field> <field name="url" set-method="setUrl" get-method="getUrl" type=" java.net.URL" > <bind-xml name="URL" node="element" /> </field> <field name="urlHash" set-method="setUrlHash" get-method="getUrlHash" type="string" > <bind-xml name="URLHASH" node="attribute" /> </field> <field name="recommenderSelectionData" set-method="setRecommenderSelectionData" get-method="getRecommenderSelectionData" type=" util.result.RecommenderSelectionData" collection="arraylist"> <bind-xml name="RECOMMENDER_SELECTION_DATA" node="element" /> </field> </class> </mapping> I would appreciate any help or suggestions as I'm using the marshalling for a Web application and the time delay for marshalling 10 or so objects when generating a Web page is unacceptable (up to 10 seconds). I've seen Castor being used in the same way for other Web applications which do not seem to suffer from this speed problem and they are using Castor in the same way as I am. Many thanks and looking forward to all replies, Oisin.

