Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializing arguments to remote methods

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just curious what you are going to do with a remote OutputStream?
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic