Issue Details (XML | Word | Printable)

Key: AXIS-2593
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Christian Gosselin
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Axis

java.lang.IllegalArgumentException: array element type mismatch

Created: 17/Nov/06 04:08 PM   Updated: 17/Nov/06 04:08 PM
Component/s: Serialization/Deserialization
Affects Version/s: 1.4
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Server: axis 1.4, tomcat 5.0.30, windows xp
Client: .net 2.0, windows xp


 Description  « Hide
Problem:
BeanPropertyTarget unable to convert an array into it's component type

Consequence:
in some rare cases client received a java.lang.IllegalArgumentException: array element type mismatch, due to a deserialization problem.

herein you'll find:
-part of the wsdl
-part of the soap message
-part of the axis stack trace
-modification to the BeanPropertyTarget.java to fix the problem

part of the wsdl:
<!-- ... -->
   <complexType name="ResourceArray">
    <sequence>
     <element name="resourceArray" nillable="true" type="impl:ArrayOf_tns4_Resource"/>
    </sequence>
   </complexType>
   <complexType name="ArrayOf_tns4_Resource">
    <complexContent>
     <restriction base="soapenc:Array">
      <attribute ref="soapenc:arrayType" wsdl:arrayType="tns4:Resource[]"/>
     </restriction>
    </complexContent>
<!-- ... -->
   <wsdl:message name="sendNotificationRequest">
      <wsdl:part name="recipients" type="tns28:ResourceArray"/>
   </wsdl:message>
<!-- ... -->

part of the SOAP message:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns=" http://interfaces.rpm.ibm.com" xmlns:types="http://interfaces.rpm.ibm.com/encodedTypes" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body soap:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/">
        <tns:sendNotification>
            <sessionID xsi:type="xsd:string">2458669038908702720</sessionID>
            <recipients href="#id3"/>
        </tns:sendNotification>
        <q3:ResourceArray id="id3" xsi:type="q3:ResourceArray" xmlns:q3="http://wrapper.interfaces.rpm.ibm.com ">
            <resourceArray href="#id10"/>
        </q3:ResourceArray>
        <soapenc:Array id="id10" xmlns:q10=" http://containers.resource.rpm.ibm.com" soapenc:arrayType="q10:Resource[1]">
            <Item href="#id21"/>
        </soapenc:Array>
        <q21:Resource id="id21" xsi:type="q21:Resource" xmlns:q21=" http://containers.resource.rpm.ibm.com">
            <ID xsi:type="xsd:string">530E213D72604A0E8F0DC719C33B4310</ID>
        </q21:Resource>
    </soap:Body>
</soap:Envelope>

part of the stack trace:
Caused by: java.lang.IllegalArgumentException: array element type mismatch
    at java.lang.reflect.Array.set(Native Method)
    at org.apache.axis.utils.BeanPropertyDescriptor.set(BeanPropertyDescriptor.java:195)
    at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:102)
    at org.apache.axis.encoding.DeserializerImpl.valueComplete (DeserializerImpl.java:249)
    at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
    at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171)
    at org.apache.axis.message.MessageElement.publishToHandler (MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:369)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.encoding.DeserializerImpl.startElement (DeserializerImpl.java:369)
    at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:158)
    at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java :1048)
    at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
    at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
    at org.apache.axis.message.RPCElement.deserialize (RPCElement.java:236)
    at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
    at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:81)
    at org.apache.axis.providers.java.JavaProvider.invoke (JavaProvider.java:323)

modification to the BeanPropertyTarget.java to fix the problem:
in the set(Object value), in the first caught exception I removed the : Object item = JavaUtils.convert(Array.get(value, i), type); since it was always returning an array which end up throwing an illegal argument exception from the pd.set(...) method. So the "if" clause within the catch block would look like this:
                if (JavaUtils.isConvertable(value, type)
                        && !value.getClass().isArray())
                {
                    value = JavaUtils.convert(value, type);
                    if (index < 0)
                        pd.set(object, value);
                    else
                        pd.set(object, index, value);
                } else {
                    // It is possible that an indexed
                    // format was expected, but the
                    // entire array was sent. In such
                    // cases traverse the array and
                    // call the setter for each item.
                    if (index == 0 &&
                        value.getClass().isArray()
                        ) {
                        for (int i = 0; i < Array.getLength(value); i++)
                        {
                            Object item = JavaUtils.convert(
                                Array.get(value, i), type.getComponentType());
                            pd.set(object, i, item);
                        }
                    }


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.