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

Reply via email to