Thank you Mark for replying.
Client and server are running on the different machines. And I was thinking
of sending my stream any any output form weather ObjectOutputStram or
FileOutputStram. I guess thats the problem with FileOutputStream.
Now I use ByteArrayInputStream and manage to get the output.
-----Original Message-----
From: Mark Phelps [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 15, 2001 1:00 PM
To: JRun-Talk
Subject: RE: Serialization problem.
Is the client code that is using the EJB running on the same machine as the
EJB? FileInputStream and FileOutputStream operate on the local file system.
Your EJB will write the file to the file system on its machine. When your
client retrieves the FileInputStream it will then attempt to read the file
from the client's local file system. If this is not the same file system as
the EJB was using, you will get nothing.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 14, 2001 1:58 PM
To: JRun-Talk
Subject: Serialization problem.
Hi all,
I am trying to get a FileInputStream object on a EJB bean. Because
FileInputStream doesn't implement serializable interface so I created a
class that contains FileInputStream object and implements writeObject() and
readObject
Following is the class
***********************************************
public class ASIFileInputStream implements Serializable {
private FileInputStream fis = null;
public ASIFileInputStream(File dbFile) throws IOException {
fis = new FileInputStream(dbFile);
}
public void writeObject() throws IOException {
FileOutputStream fos = new FileOutputStream("asitest");
ObjectOutputStream out = new ObjectOutputStream(fos);
out.writeObject(fis);
out.flush();
}
public void readObject() throws IOException, ClassNotFoundException
{
FileInputStream fi = new FileInputStream("asitest");
ObjectInputStream ois = new ObjectInputStream(fi);
fis = (FileInputStream)ois.readObject();
}
public FileInputStream getFileInputStream() {
return fis;
}
}
****************************************************************************
I am creating an object of above class inside EJB Bean and calling
writeObject() method to write FileInputStream data. And Finally returning
ASIFileInputStream object from ejb function.
Now I use the following code to call ejb and get that FileInputStream
***********************************************************
InitialContext context = new InitialContext(environment);
Object obj =
context.lookup("java:comp/env/ejb/asi.XMLDataFile");
XMLDataFileHome dataFileHome =
(XMLDataFileHome)javax.rmi.PortableRemoteObject.narrow(obj,
XMLDataFileHome.class);
XMLDataFile file = dataFileHome.create("");
ASIFileInputStream afis =
file.getXMLDataFile(dsFullPath);
afis.readObject();
FileInputStream fis = afis.getFileInputStream();
*****************************************************************
But it fails and return nothing.
Has anybody ever tried sending FileInputStream or any other stream through
EJB.
Thanks for help in advance.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists