Hi Eugene,

The item-type attribute on a collection only works when you have a 
<mapping> defined for the item-type, not with a <format> (the difference 
being that the former defines an element, while the latter just gives a 
text value - and you need elements for the items in the collection). I 
see this isn't actually spelled out in the documentation for the 
<collection> element, though the tutorial examples state things pretty 
clearly.

You should be able to instead use a nested <value> element within the 
<collection> to do what you want, like this:

  <collection ...>
    <value name='cred'/>
  </collection>

or this:

  <collection field='...' type='...' usage='optional' get-method='...' 
set-method='...'> (no item-type)
    <value name='cred' 
type='com.mycompany.myappmodule.hooks.auth.Credential'/>
  </collection>

  - 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



Eugeny N Dzhurinsky wrote:
> On Tue, Jul 10, 2007 at 11:56:24AM +0300, Eugeny N Dzhurinsky wrote:
>   
>> Hello!
>>
>> Could somebody please explain, how is it possible to use custom serializer 
>> for
>> serializing items in collection?
>>
>> I created a class with static serialize/deserialize methods, added the format
>> element to jibx-mapping, everything is compiled, but when running the
>> application I'm getting 
>>
>> ERROR [com.mycompany.myapp.Monitor.Monitor] java.lang.ClassCastException: 
>> com.mycompany.myappmodule.hooks.auth.Credential
>> java.lang.ClassCastException: com.mycompany.myappmodule.hooks.auth.Credential
>>         at 
>> com.mycompany.myapp.Network.JiBX_MungeAdapter.JiBX_linktiger_binding_marshal_1_0()
>>         at 
>> com.mycompany.myapp.Network.URLRequest.JiBX_linktiger_binding_marshal_2_0(URLRequest.java)
>>         at 
>> com.mycompany.myapp.Network.JiBX_linktiger_bindingURLRequest_access.marshal()
>>     
>
>
> the mapping looks like this:
>
>     ...
>
>     <format type="com.mycompany.myappmodule.hooks.auth.Credential"
>         serializer="com.mycompany.myapp.Common.CredentialSerializer.serialize"
>         
> deserializer="com.mycompany.myapp.Common.CredentialSerializer.deserialize"
>         />
>     
>     .....
>
>         <collection field='cred_list' type='java.util.ArrayList' 
> usage="optional"
>             item-type='com.mycompany.myappmodule.hooks.auth.Credential' 
>             get-method="getCredentialsList" set-method="setCredentialsList" />
>
>   

-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to