This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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.