This might not be ideal, but you could create two distinct classes for
your lists, a bit like this:

StringList.java: 
import java.util.ArrayList;
public class StringList extends ArrayList<String> {
/*get all functionality from super*/}

SomeBeanList.java:
import java.util.ArrayList;
public class SomeBeanList extends ArrayList<SomeBean> {
/*get all functionality from super*/}

-----Original Message-----
From: Tudor Groza [mailto:[EMAIL PROTECTED] 
Sent: 20. februar 2007 17:40
To: [email protected]
Subject: [xfire-user] XFire bug - overwritten type registration for
multiple lists


Hi,

We work with XFire version 1.2.4, with dynamic clients.

We have a service with a method like:
public Map<String, List<SomeBean>> test(List<String> stringList)

For the client to be able to serialize / deserialize correctly the
parameters
and return values, we register the types:

- list of String
- SomeBean
- list of SomeBean
- map of String to List of SomeBean

----------------------

AegisBindingProvider bindingProvider = (AegisBindingProvider) client
        
.getService().getBindingProvider();
TypeMapping tm = bindingProvider.getTypeMappingRegistry()
        
.getDefaultTypeMapping();

Type someBeanType = new BeanType();
someBeanType.setTypeClass(SomeBean.class);
someBeanType.setSchemaType(new QName(namespace, name));
tm.register(someBeanType);

Type listOfStringType = new CollectionType(new StringType());
listOfStringType.setTypeClass(List.class);
listOfStringType.setSchemaType(new QName(namespace, name));
tm.register(listOfStringType);

Type listOfBeansType = new CollectionType(someBeanType);
listOfBeansType.setTypeClass(List.class);
listOfBeansType.setSchemaType(new QName(namespace, name));
tm.register(listOfBeansType);

but when we do:

List<String> param = new List<String>();
param.add("testing");
Map result = client.invoke("test", new Object[] {param});

we get:

org.codehaus.xfire.fault.XFireFault: Couldn't get property
{namespace}field1
from bean one. Nested exception is java.lang.IllegalArgumentException:
object
is not an instance of declaring class
        at
org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
        at
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
        at org.codehaus.xfire.client.Client.invoke(Client.java:335)
        at org.codehaus.xfire.client.Client.invoke(Client.java:349)
        at TestXfire.main(TestXfire.java:88)
Caused by: org.codehaus.xfire.XFireRuntimeException: Couldn't get
property
{namespace}field1 from bean one. Nested exception is
java.lang.IllegalArgumentException: object is not an instance of
declaring
class
        at
org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:
446)
        at
org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:3
77)
        at
org.codehaus.xfire.aegis.type.basic.ArrayType.writeValue(ArrayType.java:
293)
        at
org.codehaus.xfire.aegis.type.collection.CollectionType.writeObject(Coll
ectio
nType.java:103) at
org.codehaus.xfire.aegis.type.basic.ObjectType.writeObject(ObjectType.ja
va:20
7) at
org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindin
gProv
ider.java:222) at
org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(Abstra
ctBin
ding.java:273) at
org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBi
nding
.java:89) at
org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:
80)
        at
org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(Ht
tpCha
nnel.java:56) at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayR
eques
tEntity(CommonsHttpMessageSender.java:388) at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsH
ttpMe
ssageSender.java:326) at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.
java:
123) at
 org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java
:26)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:1
31)
        at
org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
        ... 3 more
Caused by: java.lang.IllegalArgumentException: object is not an instance
of
declaring class
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.
java:25) at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:
442)
        ... 19 more


After debuging with the XFire source code, we found that most likely our
problem originates form the fact the the TypeMappingRegistry holds the
type
information in a hash map, having as key the class of the type. In our
case,
this leads to the overwriting of the List<String> with the
List<SomeBean>.

Is there a fix or a workaround for this?
Any help is really appreciated! Thank you!

Cheers,
Tudor

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to