aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Why RMI server called no-argument constructor of Data class?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Why RMI server called no-argument constructor of Data class??" Watch "Why RMI server called no-argument constructor of Data class??" New topic
Author

Why RMI server called no-argument constructor of Data class??

May Wong
Greenhorn

Joined: Feb 19, 2002
Posts: 8
Hi,
I just finished implementing the RMI mechanism to realize the remote data access. When I tried to run it, a "Data class missing no-argument constructor" exception popped up from RMI client side.
The followings are what I did,
1. Defined a RMI Client interface:
public interface RMIClientIF extends Serializable
2. Defined a RMI Client class by extending Data class.
public class RMIClient extends Data implements RMIClientIF
3. Then I created a RMIClient (client_) and forward it to server to get the necessary data:
...
client_ = new RMIClient();
...
this.remoteAgt_ = (RMIServerIF) Naming.lookup(rmi_object_name_);
...
When it goes to the next line, Data() will be called from server side.
remoteAgt_.getFieldInfo(client_);
In RMIClient() constructor I used
super(strDataBaseName);
to call Data class constructor, but why the server use no-argument constructor??
If you have any idea about this, could you please give me some hint?
Thank you for your time.
May
roger m
Greenhorn

Joined: Mar 18, 2002
Posts: 1
I am not sure what you are trying to do here, but I can tell you why it is calling the default constructor. You have a class RMIClient which is Serializable, but it extends a class (Data) which is not. When the Java de-serializes an object it will attempt to call default constructors on any super classes which are not serializable. Basicly, for a class to be serializable there are restrictions on its memember variables (they must be primitives, transitive, or implement serilaizable) and there are restrictions on the super class. It must be serializable or have a default constructor.
I somewhat doubt if you want to make Data serializable, so you likly want to re-think your design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why RMI server called no-argument constructor of Data class??