• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic