EJB File serialization


EJB design: EJB File serialization

  1. EJB File serialization (1 messages)

    I have a project with a firm requirement to serialize image files (multi-page tiffs) to client applications.

    What I'd like to do is create a stateless session EJB that find the file given the correct identifier (not an insignificant task in our system), and serializes the contents of the file to its client, which is most likely a web-tier component (servlet) but could also be a thick application client. I know how to create a servlet that could serialize a file to its client using the request output stream, but there is not output stream to write to in a session EJB... so what to do? I'd like to avoid having the io calls directly in a servlet. Is there any way to do what I'm describing.

    BTW, I am aware of the restriction that EJB's aren't supposed to be able to use the java.io.* classes, and that I'm supposed to write a resource adapter to do the io. The documentation I can find on how to write a resource adapter is sparse and not very clear, so I decided to give it a shot and see if I could open and read a file using java.io.FileInputStream in a session EJB in JBoss and it worked. Even if I do end up writing a resource adapter to do the java.io work, I'll still have the problem of how to serialize the bytes in the file to the remote client.
  2. EJB File serialization[ Go to top ]


    client and ejb use "java serialized object" to comunicate between them so you can't use any stream type because stream aren't serializable.

    you can use an byte array object to send images from ejb to it's client. Than client code can "write" an byte array to it's output stream.

    I hope this can be helpfull.

    Bye, Stefano