axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kyle Cronin <kyle.cro...@wrycan.com>
Subject Exception while deserializing abstract JavaBean
Date Mon, 25 Oct 2004 20:41:01 GMT
I get the following error when when receiving a SOAP response. The 
method returns an array of ActionDescriptor's (ActionDescriptor[]).

ActionDescriptor extends AbstractDescriptor, and as the name suggests 
AbstractDescriptor is an abstract class.

When the method service.getAllActionDescriptors() is invoked the 
following exception is thrown:

org.xml.sax.SAXException: Unable to create JavaBean of type 
com.wrycan.AbstractDescriptor.  Missing default constructor?  Error was: 
java.lang.InstantiationException.
    at 
org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:124)
    at 
org.apache.axis.encoding.DeserializerImpl.onStartElement(DeserializerImpl.java:451)
    at 
org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:395)
.....

I'm using the wsdl2java tool to generate the client source. The 
generated AbstractDesctriptor class is abstract so when the deserializer 
is called,
   (copied from axis1.2-beta-3 source)
 public BeanDeserializer(Class javaType, QName xmlType, TypeDesc 
typeDesc,  Map propertyMap ) {
        this.xmlType = xmlType;
        this.javaType = javaType;
        this.typeDesc = typeDesc;
        this.propertyMap = propertyMap;

        // create a value
        try {
            value=javaType.newInstance(); // <------- Exception thrown 
decause the generated class is abstract
        } catch (Exception e) {
            // Don't process the exception at this point.
            // This is defered until the call to startElement
            // which will throw the exception.
        }
    }

Is this a bug or am I missing a setting when generating the client 
source from the wsdl? any help would be appreciated!

Thanks.

My settings
-------------------------
axis version: 1.2-beta-3
message type: RPC/encd

*using the java2wsdl and wsdl2java to generate the server-config.wsdd 
and client source. The type mapping version is set to 1.2
generated type mappings:
...
<typeMapping encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory" 
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory" 
type="java:com.wrycan.ActionDescriptor[]" 
qname="ns23:ArrayOf_tns5_ActionDescriptor" xmlns:ns23="urn:SoapService"/>
  <typeMapping encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" 
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" 
type="java:com.wrycan.AbstractDescriptor" 
qname="ns26:AbstractDescriptor" xmlns:ns26="http://wrycan.com"/>
  <typeMapping encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" 
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory" 
type="java:com.wrycan.ActionDescriptor" qname="ns32:ActionDescriptor" 
xmlns:ns32="http://wrycan.com"/>
...

generated wsdl:
...
<complexType abstract="true" name="AbstractDescriptor">
    <sequence>
        <element name="id" type="xsd:int"/>
        <element name="parent" nillable="true" 
type="tns6:AbstractDescriptor"/>
    </sequence>
</complexType>
...
<complexType name="ActionDescriptor">
    <complexContent>
        <extension base="tns6:AbstractDescriptor">
            <sequence>
                .... elements ...
            </sequence>
        </extension>
    </complexContent>
</complexType>

-- 
Kyle Cronin
Consultant at Wrycan, Inc.

kyle.cronin@wrycan.com
http://www.wrycan.com



Mime
View raw message