• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Serializing arguments to remote methods

 
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just curious what you are going to do with a remote OutputStream?
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic