Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Working with file-system in EJBs  RSS feed

 
praveenK soni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My application requires a excel file to be saved on server hard disk. Later a user can view a file saved earlier.
To implement it I am using the classes provided in java.io package. <br>
The application is working fine on non-clustered environment. But the application is going to be deployed on clustered environment.<br>
I read somewhere that reading/writing a file from EJBs should be avoided especially on clustered environment.
This has raised some doubts in my mind:<br>
 (i)  Will the code fail on clustered environment?<br>
 (ii) What other alternatives are open to resolve the problem?<br>
 (iii) Will putting the IO code in simple java class & calling it from EJB solve the problem?
<br>
Please help. <br>
Thanks<br>
Praveen
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(i)The code is open to failure. Suppose you make a call in a Stateless Session bean to save a file, then make a seperate call in a Statless Session Bean to read it - what guarentees do you have that the beans have access to the same file systems, given they could be running on two different servers?
(ii)A Resource Adapter is the route you have round this problem. There are already opensource projects out there which do this (sorry, I can't remember any names right now - perhaps someone else will, or you can just search sourceforge etc. ), or you could write your own.
(iii)No. You still have the same problem as (i) - on which physical machine is the code running on?
 
praveenK soni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul for your response.
But if we can not use java IO in any java class used in a web-application then do you want to say that java IO can not be used in a web based application not even in a servlet?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!