You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Andrey A. Chujko" <ac...@googlemail.com> on 2007/05/15 13:23:42 UTC

Axis2 + JiBX, polymorphic types unmarshaling

Hi all,

I have set of objects being extended from another one:

<wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="http://ns.url.com/">
      <s:complexType name="Product" abstract="true">
        <s:sequence>
           ...
        </s:sequence>
        ...
      </s:complexType>
      <s:complexType name="Application">
        <s:complexContent mixed="false">
          <s:extension base="tns:Product">
            <s:sequence>
              ...
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
      <s:complexType name="Logo">
        <s:complexContent mixed="false">
          <s:extension base="tns:Product">
            <s:sequence>
              ...
            </s:sequence>
          </s:extension>
        </s:complexContent>
      </s:complexType>
    </s:schema>
</wsdl:types>


The JiBX binding is following:

<binding xmlns:tns="http://ns.url.com/" force-classes="true" add-constructors="false">
   ...
   <mapping abstract="true" class="model.Product" type-name="tns:Product">
      ...
   </mapping>
   <mapping abstract="true" class="model.Product" name="Product">
       <structure map-as="tns:Product"/>
   </mapping>

   <mapping class="model.Application" name="Application" extends="model.Product">
       ...
   </mapping>

   <mapping class="model.Logo" name="Logo" extends="model.Product">
       ...
   </mapping>
</binding>


All stubs have been generated successfully, but compilation is failed with following messages:

   ...
   [javac] /home/zzz/ContentSoap12Stub.java:1734: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoap12Stub.java:2407: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoap12Stub.java:4545: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoap12Stub.java:5302: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoapStub.java:1731: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoapStub.java:2404: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoapStub.java:4542: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   [javac]                                                      ^
   [javac] /home/zzz/ContentSoapStub.java:5299: model.Product is abstract; cannot be instantiated
   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
   ...

I'm stuck with that issue.
Does someone of you guys has any idea why it trying to instantiate base abstract class and how I could solve that? Am I doing something wrong?

Any help will be appreciated greatly.

Thanks,
Andrey.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 + JiBX, polymorphic types unmarshaling

Posted by "Andrey A. Chujko" <ac...@googlemail.com>.
Hello All,

Dennis, it seams I've found where the problem is...

In your example3 you are using of explicit Lists definitions:
<xsd:complexType name="itemList">
   <xsd:sequence>
      <xsd:element ref="ns1:item" minOccurs="0" maxOccurs="unbounded"/>
   </xsd:sequence>
</xsd:complexType>
and
<mapping abstract="true" type-name="tns:itemList" class="java.util.List" create-type="java.util.ArrayList">
    <collection item-type="com.sosnoski.ws.library.jibx2wsdl.Item"/>
</mapping>

But not me:
<s:element name="GetProductsResponse">
  <s:complexType>
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="GetProductsResult" nillable="true" type="tns:Product" />
    </s:sequence>
  </s:complexType>
</s:element>


This fact somehow affects 'order' property of the NestedCollection (it becomes unordered for me), thus:
 - In YOUR case: child.genContentPresentTest(mb) method will generate of the code to test for content presence:
      if (uctx.getUnmarshaller("http://sosnoski.com/ws/library/jibx2wsdl", "item").isPresent(uctx)) {
         item = (com.sosnoski.ws.library.jibx2wsdl.Item)uctx.unmarshalElement();
      }
      ...

 - In MY case: child.genContentUnmarshal(mb) method will strictly generate of the unmarshaling code which is trying instantiate of base abstract class:
      GetProductsResult[index++] = (model.Product)uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx);
      ...

The entire unmarshaling code is in the NestedCollection.genContentUnmarshal() method of JiBX distribution.


Can I workaround this issue somehow?

Looking forward for you response.

Thanks,
Andrey.

Andrey A. Chjko wrote:
> Greetings Dennis,
> 
> Thanks a lot for your response!
> 
> Dennis Sosnoski wrote:
>>
>> I don't see anything wrong with the binding, offhand. It's very 
>> similar to the polymorphism example from the Jibx2Wsdl code at 
>> http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl/example3 
>> , and that works with the Axis2 1.2 release.
>>
>> There were problems with this in earlier versions of the Axis2 code, 
>> including the 1.1.1 code. Which version of Axis2 are you using?
> 
> I'm using of Axis2 1.2 release. And your examples (#3 including) are 
> build/bind/generate perfectly, utilizing the same Axis2 and JiBX releases.
> 
> I would be appreciated for any help further.


> Hi all,
> 
> I have set of objects being extended from another one:
> 
> <wsdl:types>
>    <s:schema elementFormDefault="qualified" targetNamespace="http://ns.url.com/">
>      <s:complexType name="Product" abstract="true">
>        <s:sequence>
>           ...
>        </s:sequence>
>        ...
>      </s:complexType>
>      <s:complexType name="Application">
>        <s:complexContent mixed="false">
>          <s:extension base="tns:Product">
>            <s:sequence>
>              ...
>            </s:sequence>
>          </s:extension>
>        </s:complexContent>
>      </s:complexType>
>      <s:complexType name="Logo">
>        <s:complexContent mixed="false">
>          <s:extension base="tns:Product">
>            <s:sequence>
>              ...
>            </s:sequence>
>          </s:extension>
>        </s:complexContent>
>      </s:complexType>
>    </s:schema>
> </wsdl:types>
> 
> 
> The JiBX binding is following:
> 
> <binding xmlns:tns="http://ns.url.com/" force-classes="true" add-constructors="false">
>   ...
>   <mapping abstract="true" class="model.Product" type-name="tns:Product">
>      ...
>   </mapping>
>   <mapping abstract="true" class="model.Product" name="Product">
>       <structure map-as="tns:Product"/>
>   </mapping>
> 
>   <mapping class="model.Application" name="Application" extends="model.Product">
>       ...
>   </mapping>
> 
>   <mapping class="model.Logo" name="Logo" extends="model.Product">
>       ...
>   </mapping>
> </binding>
> 
> 
> All stubs have been generated successfully, but compilation is failed with following messages:
> 
>   ...
>   [javac] /home/zzz/ContentSoap12Stub.java:1734: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:2407: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:4545: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:5302: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:1731: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:2404: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:4542: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:5299: model.Product is abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new model.Product(), uctx)
>   ...
> 
> I'm stuck with that issue.
> Does someone of you guys has any idea why it trying to instantiate base abstract class and how I could solve that? Am I doing something wrong?
> 
> Any help will be appreciated greatly.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 + JiBX, polymorphic types unmarshaling

Posted by "Andrey A. Ch" <ac...@googlemail.com>.
Greetings Dennis,

Thanks a lot for your response!

Dennis Sosnoski wrote:
> 
> I don't see anything wrong with the binding, offhand. It's very similar 
> to the polymorphism example from the Jibx2Wsdl code at 
> http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl/example3 , 
> and that works with the Axis2 1.2 release.
> 
> There were problems with this in earlier versions of the Axis2 code, 
> including the 1.1.1 code. Which version of Axis2 are you using?

I'm using of Axis2 1.2 release. And your examples (#3 including) are build/bind/generate perfectly, utilizing the same Axis2 and JiBX releases.

I would be appreciated for any help further.

Thanks,
Andrey.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 + JiBX, polymorphic types unmarshaling

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Hi Andrey,

I don't see anything wrong with the binding, offhand. It's very similar 
to the polymorphism example from the Jibx2Wsdl code at 
http://www.sosnoski.com/jibx-wiki/space/axis2-jibx/jibx2wsdl/example3 , 
and that works with the Axis2 1.2 release.

There were problems with this in earlier versions of the Axis2 code, 
including the 1.1.1 code. Which version of Axis2 are you using?

  - Dennis

Dennis M. Sosnoski
SOA and Web Services in Java
Axis2 Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



Andrey A. Chujko wrote:
> Hi all,
>
> I have set of objects being extended from another one:
>
> <wsdl:types>
>    <s:schema elementFormDefault="qualified" 
> targetNamespace="http://ns.url.com/">
>      <s:complexType name="Product" abstract="true">
>        <s:sequence>
>           ...
>        </s:sequence>
>        ...
>      </s:complexType>
>      <s:complexType name="Application">
>        <s:complexContent mixed="false">
>          <s:extension base="tns:Product">
>            <s:sequence>
>              ...
>            </s:sequence>
>          </s:extension>
>        </s:complexContent>
>      </s:complexType>
>      <s:complexType name="Logo">
>        <s:complexContent mixed="false">
>          <s:extension base="tns:Product">
>            <s:sequence>
>              ...
>            </s:sequence>
>          </s:extension>
>        </s:complexContent>
>      </s:complexType>
>    </s:schema>
> </wsdl:types>
>
>
> The JiBX binding is following:
>
> <binding xmlns:tns="http://ns.url.com/" force-classes="true" 
> add-constructors="false">
>   ...
>   <mapping abstract="true" class="model.Product" type-name="tns:Product">
>      ...
>   </mapping>
>   <mapping abstract="true" class="model.Product" name="Product">
>       <structure map-as="tns:Product"/>
>   </mapping>
>
>   <mapping class="model.Application" name="Application" 
> extends="model.Product">
>       ...
>   </mapping>
>
>   <mapping class="model.Logo" name="Logo" extends="model.Product">
>       ...
>   </mapping>
> </binding>
>
>
> All stubs have been generated successfully, but compilation is failed 
> with following messages:
>
>   ...
>   [javac] /home/zzz/ContentSoap12Stub.java:1734: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:2407: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:4545: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoap12Stub.java:5302: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:1731: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:2404: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:4542: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   [javac]                                                      ^
>   [javac] /home/zzz/ContentSoapStub.java:5299: model.Product is 
> abstract; cannot be instantiated
>   [javac]         uctx.getUnmarshaller(_type_index8).unmarshal(new 
> model.Product(), uctx)
>   ...
>
> I'm stuck with that issue.
> Does someone of you guys has any idea why it trying to instantiate 
> base abstract class and how I could solve that? Am I doing something 
> wrong?
>
> Any help will be appreciated greatly.
>
> Thanks,
> Andrey.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org