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 Bram Biesbrouck <b...@beligum.org> on 2006/02/25 19:28:38 UTC

[Axis2] ArrayIndexOutOfBounds driving me crazy

Hi all,

I'm having a problem with an Axis2 webservice and it's driving me nuts for all 
day now, please help me out.
Basically, it comes down to this:

My webservice returns an array of categories to my client program and when no 
categories are found, a zero-sized array is returned to indicate this. 
However, when I try to return an empty-sized array, an ArrayIndexOutOfBound 
error is thrown.
Here's the relevant WSDL scheme:

<complexType name="Category">
	<all>
		<element name="id" type="xsd:int"/>
		<element name="parent" type="xsd:int"/>
		<element name="title" type="xsd:string"/>
	</all>
</complexType>

<complexType name="CategoryArray">
	<sequence>
		<element name="category" minOccurs="0" maxOccurs="unbounded" 
type="myxsd:Category"/>
	</sequence>
</complexType>

The Java-code calls the autogenerated (WSDL2java) toEnvelope method:

org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new 
org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(com.bpower2.ws.instrudeo.xsd.AvailableCategoriesResponse.MY_QNAME),	
factory);
return builder.getEnvelope();

When I debug this (autogenerated) piece of code with a breakpoint on the 
return statement, the debugger says

"com.sun.jdi.InvocationException occurred invoking method"

when inspecting the "body" member of the "builder" variable, so I guess the 
problem must be around that position somewhere.

I hope this is enough information. Please help me out with this one, I'm 
debugging for all damn day now and you're my last resort.

Bram

Re: [Axis2] ArrayIndexOutOfBounds driving me crazy

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi,
ADB is the Axis2 databinding framework with simple schema support. ADB
(even though the default) is not meant to support all the schema
constructs but acts as a 80% case for the databinding needs.
XMLBeans on the other  hand is a full blown XML to Object mapping
(http://xmlbeans.apache.org/) and supports almost all the schema
constructs (from my experience it did not fail to any of the schemas
yet!). Axis2 supports the use of XMLBeans databinding framework .You
can switch the databinding implementation by using the -d switch, use
-d xmlbeans to generate XMLBeans stubs.
BTW for XMLBeans you would be better off in reading some documentation
before you drill down into the details.

Ajith

On 2/26/06, Bram Biesbrouck <b...@beligum.org> wrote:
> Hi,
>
> Yes, I'm using ADB. I tried to change to sequence instead of all, but nothing
> changed. I'm implementing a workaround now by returning an 'empty'-element,
> but that's not good coding style IMHO.
> Didn't try with XMLBeans yet. Could you tell me what's the difference between
> the two?
>
> Bram
>
> Op zondag 26 februari 2006 02:40, schreef Ajith Ranabahu:
> > Hi Bram,
> > Are you using ADB ? if so the <all/> schema construct can be an issue.
> > A recently done change to the deser code of ADB only supports
> > sequence. So here are two things you can try out!
> > 1. Change all to sequence. However the sequence requires the elements
> > to be properly ordered!
> > 2. Try using XMLBeans.(it should handle all these schema constructs
> > properly!).
> >
> >
> > Ajith
> >
> > On 2/25/06, Bram Biesbrouck <b...@beligum.org> wrote:
> > > Hi all,
> > >
> > > I'm having a problem with an Axis2 webservice and it's driving me nuts
> > > for all day now, please help me out.
> > > Basically, it comes down to this:
> > >
> > > My webservice returns an array of categories to my client program and
> > > when no categories are found, a zero-sized array is returned to indicate
> > > this. However, when I try to return an empty-sized array, an
> > > ArrayIndexOutOfBound error is thrown.
> > > Here's the relevant WSDL scheme:
> > >
> > > <complexType name="Category">
> > >         <all>
> > >                 <element name="id" type="xsd:int"/>
> > >                 <element name="parent" type="xsd:int"/>
> > >                 <element name="title" type="xsd:string"/>
> > >         </all>
> > > </complexType>
> > >
> > > <complexType name="CategoryArray">
> > >         <sequence>
> > >                 <element name="category" minOccurs="0"
> > > maxOccurs="unbounded" type="myxsd:Category"/>
> > >         </sequence>
> > > </complexType>
> > >
> > > The Java-code calls the autogenerated (WSDL2java) toEnvelope method:
> > >
> > > org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
> > > org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(com.
> > >bpower2.ws.instrudeo.xsd.AvailableCategoriesResponse.MY_QNAME), factory);
> > > return builder.getEnvelope();
> > >
> > > When I debug this (autogenerated) piece of code with a breakpoint on the
> > > return statement, the debugger says
> > >
> > > "com.sun.jdi.InvocationException occurred invoking method"
> > >
> > > when inspecting the "body" member of the "builder" variable, so I guess
> > > the problem must be around that position somewhere.
> > >
> > > I hope this is enough information. Please help me out with this one, I'm
> > > debugging for all damn day now and you're my last resort.
> > >
> > > Bram
> >
> > --
> > Ajith Ranabahu
>


--
Ajith Ranabahu

Re: [Axis2] ArrayIndexOutOfBounds driving me crazy

Posted by Bram Biesbrouck <b...@beligum.org>.
Hi,

Yes, I'm using ADB. I tried to change to sequence instead of all, but nothing 
changed. I'm implementing a workaround now by returning an 'empty'-element, 
but that's not good coding style IMHO.
Didn't try with XMLBeans yet. Could you tell me what's the difference between 
the two?

Bram

Op zondag 26 februari 2006 02:40, schreef Ajith Ranabahu:
> Hi Bram,
> Are you using ADB ? if so the <all/> schema construct can be an issue.
> A recently done change to the deser code of ADB only supports
> sequence. So here are two things you can try out!
> 1. Change all to sequence. However the sequence requires the elements
> to be properly ordered!
> 2. Try using XMLBeans.(it should handle all these schema constructs
> properly!).
>
>
> Ajith
>
> On 2/25/06, Bram Biesbrouck <b...@beligum.org> wrote:
> > Hi all,
> >
> > I'm having a problem with an Axis2 webservice and it's driving me nuts
> > for all day now, please help me out.
> > Basically, it comes down to this:
> >
> > My webservice returns an array of categories to my client program and
> > when no categories are found, a zero-sized array is returned to indicate
> > this. However, when I try to return an empty-sized array, an
> > ArrayIndexOutOfBound error is thrown.
> > Here's the relevant WSDL scheme:
> >
> > <complexType name="Category">
> >         <all>
> >                 <element name="id" type="xsd:int"/>
> >                 <element name="parent" type="xsd:int"/>
> >                 <element name="title" type="xsd:string"/>
> >         </all>
> > </complexType>
> >
> > <complexType name="CategoryArray">
> >         <sequence>
> >                 <element name="category" minOccurs="0"
> > maxOccurs="unbounded" type="myxsd:Category"/>
> >         </sequence>
> > </complexType>
> >
> > The Java-code calls the autogenerated (WSDL2java) toEnvelope method:
> >
> > org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
> > org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(com.
> >bpower2.ws.instrudeo.xsd.AvailableCategoriesResponse.MY_QNAME), factory);
> > return builder.getEnvelope();
> >
> > When I debug this (autogenerated) piece of code with a breakpoint on the
> > return statement, the debugger says
> >
> > "com.sun.jdi.InvocationException occurred invoking method"
> >
> > when inspecting the "body" member of the "builder" variable, so I guess
> > the problem must be around that position somewhere.
> >
> > I hope this is enough information. Please help me out with this one, I'm
> > debugging for all damn day now and you're my last resort.
> >
> > Bram
>
> --
> Ajith Ranabahu

Re: [Axis2] ArrayIndexOutOfBounds driving me crazy

Posted by Ajith Ranabahu <aj...@gmail.com>.
Hi Bram,
Are you using ADB ? if so the <all/> schema construct can be an issue.
A recently done change to the deser code of ADB only supports
sequence. So here are two things you can try out!
1. Change all to sequence. However the sequence requires the elements
to be properly ordered!
2. Try using XMLBeans.(it should handle all these schema constructs properly!).


Ajith

On 2/25/06, Bram Biesbrouck <b...@beligum.org> wrote:
> Hi all,
>
> I'm having a problem with an Axis2 webservice and it's driving me nuts for all
> day now, please help me out.
> Basically, it comes down to this:
>
> My webservice returns an array of categories to my client program and when no
> categories are found, a zero-sized array is returned to indicate this.
> However, when I try to return an empty-sized array, an ArrayIndexOutOfBound
> error is thrown.
> Here's the relevant WSDL scheme:
>
> <complexType name="Category">
>         <all>
>                 <element name="id" type="xsd:int"/>
>                 <element name="parent" type="xsd:int"/>
>                 <element name="title" type="xsd:string"/>
>         </all>
> </complexType>
>
> <complexType name="CategoryArray">
>         <sequence>
>                 <element name="category" minOccurs="0" maxOccurs="unbounded"
> type="myxsd:Category"/>
>         </sequence>
> </complexType>
>
> The Java-code calls the autogenerated (WSDL2java) toEnvelope method:
>
> org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
> org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(com.bpower2.ws.instrudeo.xsd.AvailableCategoriesResponse.MY_QNAME),
> factory);
> return builder.getEnvelope();
>
> When I debug this (autogenerated) piece of code with a breakpoint on the
> return statement, the debugger says
>
> "com.sun.jdi.InvocationException occurred invoking method"
>
> when inspecting the "body" member of the "builder" variable, so I guess the
> problem must be around that position somewhere.
>
> I hope this is enough information. Please help me out with this one, I'm
> debugging for all damn day now and you're my last resort.
>
> Bram
>


--
Ajith Ranabahu