RMI - Serializing Object with the right constructor..?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ivn_Tcakov
Posted On:   Wednesday, August 13, 2003 04:04 PM

Hello, I am trying to usr RMI to send an object that I serialized but I have further porblems than that. The Object that I am using is called FileLineReader and it Extends Buffered Reader. SInce Buffered Reader is not Serializable, I implemented Serializable within FileLineReader, so that I can send it through the RMI. package musr.client.dbreader; import java.io.*; public class FileLineReader extends BufferedReader implements LineReader, java.io.Serializable { String pattern; // The string we are going to be matching. /** * Constructor * Passes the stream to our superclass */ public FileLineReader(Reader in) { super(in); }    More>>


Hello, I am trying to usr RMI to send an object that I serialized but I have further porblems than that.
The Object that I am using is called FileLineReader and it Extends Buffered Reader. SInce Buffered Reader is not Serializable, I implemented Serializable within FileLineReader, so that I can send it through the RMI.


			
package musr.client.dbreader;
import java.io.*;

public class FileLineReader extends BufferedReader
implements LineReader, java.io.Serializable {
String pattern; // The string we are going to be matching.

/**
* Constructor
* Passes the stream to our superclass
*/
public FileLineReader(Reader in) { super(in); }


/**
* This is the filter: call our superclass's readLine() to get the
* actual lines, but only return lines that contain the pattern.
* When the superclass readLine() returns null (EOF), we return null.
**/
public String matchLine(String pattern) throws IOException {
String line;
do { line = super.readLine(); }
while ((line != null) && line.indexOf(pattern) == -1);
return line;
}


}


When I use this object to send it through RMI to the Server,


(FileLineReader)inFile = (FileLineReader) obj.senddbFile(openFileTextField1.getText(),openFileTextField2.getText());


I get an exception:


GUI_RMI exception, error unmarshalling return; nested exception is:
java.io.InvalidClassException: musr.client.dbreader.FileLineReader; no valid constructor.


I am not sure what the problem is and I have been struggling with it for a while now. The constructor of BufferedReader takes one argument in so I have to pass FileLineReader an argument when I construct it. I think the RMI needs a constructor that takes no arguments and that causes problems. Is that true? In that case, I can't extend my class with BufferedReader.


Or maybe the problem is somthing quite different.
Anyone has any suggestions or comments, I'd appreciate help.
Thanks
Ivan

   <<Less

Re: RMI - Serializing Object with the right constructor..?

Posted By:   Anonymous  
Posted On:   Thursday, August 14, 2003 02:33 AM

What are you trying to do?.
Since this object extends a not serializable class (that has no serializable fields as for example a Reader), itsn't really serializable.


I don't find the point in sending this object by the wire. Are you trying to send a reference to one file in your local file system to a remote server with a different file system, where the reference is invalid?


Bye,

David

About | Sitemap | Contact