aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Serializing arguments to remote methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Serializing arguments to remote methods" Watch "Serializing arguments to remote methods" New topic
Author

Serializing arguments to remote methods

Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi

It's really such a pain that the arguments to my Session bean methods must be Serialize? I have a method that looks like this...

public ZipFileStreamWrapper getZip(Collection<String> fileCollection, OutputStream out) throws java.rmi.RemoteException;

I haven't tested it yet, but I get an info/warning like:

java.io.OutputStream must be serializable at runtime


And creating a wrapper class as some sort of workaround is really a pain in the a** if I have to do it everytime! Is there anything I can do about this?

Thanks!


SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
Just curious what you are going to do with a remote OutputStream?
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
looks like you need some system redesign.
why are you treating an OutputStream as a data object?

yes this is a limitation of EJB,
it is a limitation to all remote computing,

it definitely effects the design and messaging between tiers of your architecture,


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hmmm... So I am already doing something wrong eh? I need to implement a download functionality and currently, what I intend to do is...

1. Make a session bean that accepts an output stream
2. Create a Servlet/Struts Action class which the user would access
3. In the Servlet/Struts class, pass the ServletOutputStream to a session bean method.

Basically, the sesssion bean would be the one to make the file on the fly. Do you guys have any suggestions? Thanks!
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Your session bean should not know that its client is a servlet. Instead, write a class which creates a serializable object from the input stream. Make sure that every field in the object is also serializable. This object is then passed to the bean for processing.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Either i can not understand the requirements or there is something terribly wrong in here.

You want a download functionality as provided by a web browser?
If yes, How will doing anything on the server help you download a file on the client? (Unless ofcourse, the client machine is open to be screwed by anyone on the internet)
I think you have to run an applet on the client that fetches the file contents from the server, as a mime attachemnt of an HTTP request or may be someother way.


apigee, a better way to API!
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi

I used a File as a return type instead and removed everything except the list of files(String) argument.

Reason I need this is I have to fetch files from another Server before the client(e.g. Servlet) could then make use of it(in my case, to download).

I need the Session bean to abstract the access of the other server from the Servlet.

Thank you for your suggestions!
Timothy Sam
Ranch Hand

Joined: Sep 18, 2005
Posts: 746
Hi

I used a File as a return type instead and removed everything except the list of files(String) argument.

Reason I need this is I have to fetch files from another Server before the client(e.g. Servlet) could then make use of it(in my case, to download).

I need the Session bean to abstract the access of the other server from the Servlet.

Thank you for your suggestions!
 
 
subject: Serializing arguments to remote methods