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 albert quinn <al...@gmail.com> on 2007/07/19 09:23:09 UTC

returned object constructor issue

  Hi again !! :

  I finally do it work!!. I've find what was the problem reported in
my last post, but i don't know if there is a bug in Axis 2 or if that
is the expected behaviour, so I post again to explain it and with hope
that my experience could be helpful for any newbie who has to face the
same problem.

  I've a very simple test POJO web service returning a class named External :

package org.testing.data;

public class External {

	private String exMessage = null;
	private boolean error = false;	
                private Internal internal = null;

	public External(String exMessage, boolean error, Internal internal) {
		this.exMessage = exMessage;
		this.error = error;
		this.internal = internal;
	}
	
  // getters and setters...
	
}

package org.testing.data;

public class Internal {

	private String internal = null;

	public Internal(String internal) {
		this.internal = internal;
	}

  // getters and setters...
	
}


  That way it doesn't work and my RPC client fails, returning an
AxisFault caused by a java.lang.InstantiationException. But If I
change those classes removing the constructors :

package org.testing.data;

public class External {

	private String exMessage;
	private boolean error;	
                private Internal internal;

  // getters and setters
	
}

public class Internal {

	private String internal;

  // getters and setters...
	
}

then... it works FINE!!!!!!!!!!!!!!!!!!!!!!!, and that is vey strange
for me!!!!!!!. Is that the expected behaviour? can't I have my own
constructor in the returned objects? (If I can't, I'll need many lines
of code to do what I could have done with one line of code). does it
exist any way to avoid that and have my own constructors?.

  Thanks in advance. Regards :


Albert

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


Re: returned object constructor issue

Posted by albert quinn <al...@gmail.com>.
 Hi Deepal!! :

  Many thanks for your time and help. I didn't know the default
constructor was required in a Java Bean, but I know it now and I won't
forget it :). Thanks again.

2007/7/19, Deepal Jayasinghe <de...@opensource.lk>:
> Hi albert ,
> For a Java bean it is required to have the default constructor, it is ok
> to overload but do not remove the default constructor.
>
> Thanks
> Deepal
> >  Hi again !! :
> >
> >  I finally do it work!!. I've find what was the problem reported in
> > my last post, but i don't know if there is a bug in Axis 2 or if that
> > is the expected behaviour, so I post again to explain it and with hope
> > that my experience could be helpful for any newbie who has to face the
> > same problem.
> >
> >  I've a very simple test POJO web service returning a class named
> > External :
> >
> > package org.testing.data;
> >
> > public class External {
> >
> >     private String exMessage = null;
> >     private boolean error = false;
> >                private Internal internal = null;
> >
> >     public External(String exMessage, boolean error, Internal internal) {
> >         this.exMessage = exMessage;
> >         this.error = error;
> >         this.internal = internal;
> >     }
> >
> >  // getters and setters...
> >
> > }
> >
> > package org.testing.data;
> >
> > public class Internal {
> >
> >     private String internal = null;
> >
> >     public Internal(String internal) {
> >         this.internal = internal;
> >     }
> >
> >  // getters and setters...
> >
> > }
> >
> >
> >  That way it doesn't work and my RPC client fails, returning an
> > AxisFault caused by a java.lang.InstantiationException. But If I
> > change those classes removing the constructors :
> >
> > package org.testing.data;
> >
> > public class External {
> >
> >     private String exMessage;
> >     private boolean error;
> >                private Internal internal;
> >
> >  // getters and setters
> >
> > }
> >
> > public class Internal {
> >
> >     private String internal;
> >
> >  // getters and setters...
> >
> > }
> >
> > then... it works FINE!!!!!!!!!!!!!!!!!!!!!!!, and that is vey strange
> > for me!!!!!!!. Is that the expected behaviour? can't I have my own
> > constructor in the returned objects? (If I can't, I'll need many lines
> > of code to do what I could have done with one line of code). does it
> > exist any way to avoid that and have my own constructors?.
> >
> >  Thanks in advance. Regards :
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> 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


Re: returned object constructor issue

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi albert ,
For a Java bean it is required to have the default constructor, it is ok
to overload but do not remove the default constructor.

Thanks
Deepal
>  Hi again !! :
>
>  I finally do it work!!. I've find what was the problem reported in
> my last post, but i don't know if there is a bug in Axis 2 or if that
> is the expected behaviour, so I post again to explain it and with hope
> that my experience could be helpful for any newbie who has to face the
> same problem.
>
>  I've a very simple test POJO web service returning a class named
> External :
>
> package org.testing.data;
>
> public class External {
>
>     private String exMessage = null;
>     private boolean error = false;   
>                private Internal internal = null;
>
>     public External(String exMessage, boolean error, Internal internal) {
>         this.exMessage = exMessage;
>         this.error = error;
>         this.internal = internal;
>     }
>     
>  // getters and setters...
>     
> }
>
> package org.testing.data;
>
> public class Internal {
>
>     private String internal = null;
>
>     public Internal(String internal) {
>         this.internal = internal;
>     }
>
>  // getters and setters...
>     
> }
>
>
>  That way it doesn't work and my RPC client fails, returning an
> AxisFault caused by a java.lang.InstantiationException. But If I
> change those classes removing the constructors :
>
> package org.testing.data;
>
> public class External {
>
>     private String exMessage;
>     private boolean error;   
>                private Internal internal;
>
>  // getters and setters
>     
> }
>
> public class Internal {
>
>     private String internal;
>
>  // getters and setters...
>     
> }
>
> then... it works FINE!!!!!!!!!!!!!!!!!!!!!!!, and that is vey strange
> for me!!!!!!!. Is that the expected behaviour? can't I have my own
> constructor in the returned objects? (If I can't, I'll need many lines
> of code to do what I could have done with one line of code). does it
> exist any way to avoid that and have my own constructors?.
>
>  Thanks in advance. Regards :
>
>




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


RE: returned object constructor issue

Posted by Brian Neate <bn...@alarmpoint.com>.
I believe the problem is that if you create your own constructor you
also need to have a default no argument constructor.  For example if you
have:
	public Internal(String internal) {
		this.internal = internal;
	}
You must also have:
	public Internal() {
	} 

And then everything should work fine.

Brian

-----Original Message-----
From: albert quinn [mailto:albertbertal@gmail.com] 
Sent: Thursday, July 19, 2007 12:23 AM
To: axis-user@ws.apache.org
Subject: returned object constructor issue

  Hi again !! :

  I finally do it work!!. I've find what was the problem reported in my
last post, but i don't know if there is a bug in Axis 2 or if that is
the expected behaviour, so I post again to explain it and with hope that
my experience could be helpful for any newbie who has to face the same
problem.

  I've a very simple test POJO web service returning a class named
External :

package org.testing.data;

public class External {

	private String exMessage = null;
	private boolean error = false;	
                private Internal internal = null;

	public External(String exMessage, boolean error, Internal
internal) {
		this.exMessage = exMessage;
		this.error = error;
		this.internal = internal;
	}
	
  // getters and setters...
	
}

package org.testing.data;

public class Internal {

	private String internal = null;

	public Internal(String internal) {
		this.internal = internal;
	}

  // getters and setters...
	
}


  That way it doesn't work and my RPC client fails, returning an
AxisFault caused by a java.lang.InstantiationException. But If I change
those classes removing the constructors :

package org.testing.data;

public class External {

	private String exMessage;
	private boolean error;	
                private Internal internal;

  // getters and setters
	
}

public class Internal {

	private String internal;

  // getters and setters...
	
}

then... it works FINE!!!!!!!!!!!!!!!!!!!!!!!, and that is vey strange
for me!!!!!!!. Is that the expected behaviour? can't I have my own
constructor in the returned objects? (If I can't, I'll need many lines
of code to do what I could have done with one line of code). does it
exist any way to avoid that and have my own constructors?.

  Thanks in advance. Regards :


Albert

---------------------------------------------------------------------
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